error using DatePicker control

Here is my code:

Why am I getting these errors? Error CS1662 Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type JobCosting C:\G\Clients\Oxford Machine & Welding\JobCosting_Identity_June_1\JobCosting\JobCosting\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Quotations_AddQuotation2_razor.g.cs 240 Active Error CS1503 Argument 2: cannot convert from 'Microsoft.AspNetCore.Components.EventCallback

' to 'Microsoft.AspNetCore.Components.EventCallback' JobCosting C:\G\Clients\Oxford Machine & Welding\JobCosting_Identity_June_1\JobCosting\JobCosting\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Quotations_AddQuotation2_razor.g.cs 499 Active I have referenced: @using Syncfusion.Blazor.Calendars in my page.

3 Replies

UD UdhayaKumar Duraisamy Syncfusion Team June 6, 2022 02:10 PM UTC

Hi Miles,


We suspect that you are using events in the DatePicker component. The issue will produce when we declare wrong arguments to the events. We have added a sample and code snippet for reference.


@using Syncfusion.Blazor.Calendars

 

<SfDatePicker TValue="DateTime?">

    <DatePickerEvents TValue="DateTime?" ValueChange="ValueChangeHandler"></DatePickerEvents>

</SfDatePicker>

@code{

 

    public void ValueChangeHandler(ChangedEventArgs<DateTime?> args)

    {

        // Here, you can customize your code.

    }

}


Documentation : https://blazor.syncfusion.com/documentation/datepicker/events


Let us know if you have faced any problems with the above suggestion and we request you to share the details about your validation logic and use case details elaborately. This will help us to provide you with a better solution.


Regards,

Udhaya Kumar D


Attachment: DatePicker_(2)_cae684a8.zip


MG Miles Gibson June 6, 2022 04:09 PM UTC

So your DatePickerEvents handler works if the date variable is nullable.  But it blows up for any variable specified as follows:


                    <SfDatePicker TValue="DateTime" Placeholder="Quotation Date" @bind-Value="@QuotationDate" ShowClearButton="true" >

                          <DatePickerEvents TValue="DateTime" OnRenderDayCell="onRenderDayCellHandler"></DatePickerEvents>

                    </SfDatePicker>


HTH,

Miles



UD UdhayaKumar Duraisamy Syncfusion Team June 7, 2022 04:11 PM UTC

Hi Miles,


In DatePicker, The Value property is set to null when we click on the clear button. So, setting the null value to a non-nullable type (DateTime)
the results in the console exception. So, if you are using the clear button kindly provide nullable types to the component.


Regards,

Udhaya Kumar D.


Loader.
Up arrow icon