I am newbie with QuickGrid and .Net-8.
I get this error for the Blazor QuickGrid .net-8.
Error (active) CS1061 'DateTime?' does not contain a definition for 'Year' and no accessible extension method 'Year' accepting a first argument of type 'DateTime?' could be found (are you missing a using directive or an assembly reference?)
I really don't understand the error text, and don't know how to fix this error. Can this be fixed? Thanks.
The QuickGrid works perfectly for the PropertyColumns. However, the above error appears during compilation for the TemplateColumn shown below.
<PropertyColumn Property="f => f.DT_END" Format="MM/dd/yyyy" Title="End Date" Sortable="false"/>
<TemplateColumn>
<div>
<span>@(_FilteredVehicles.First(r => r.UID_VEHICLE == context.UID_VEHICLE).DT_END!.Year.ToString())</span>
</div>
</TemplateColumn>
// ////////////////////////////////////////////////////////////
After the above compilation error no longer appears, thanks to @MisterMagoo, I now get this error that I do not understand.
Error (active) RZ9999 The child content element 'ChildContent' of component 'TemplateColumn' uses the same parameter name ('context') as enclosing child content element 'ChildContent' of component 'AuthorizeView'. Specify the parameter name like: ' to resolve the ambiguity
It looks like DT_END
is Nullable
, the equivalent of Nullable<DateTime>
- which means you need to get the Value
either explicitly
DT_END.Value.Year
- which could throw an exception
or by using the null conditional operator
DT_END?.Year
which is what I recommend for you here.