We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Null check on Datasource

Hi,

When setting the datasource as the result of a call to an API do we need to check if the datasource is not null before rendering the dropdownlist?  


For example, here we are checking that the datasource is not null - do we need to do this or will the control handle this for us?

 @if (workflowTasksActivities != null)

                    {

                        <SfDropDownList CssClass="bg-light-gray border small m-0" TItem="WorkflowTasksActivity" Placeholder="Select Workflow Activity" TValue="int?" PopupHeight="auto" DataSource="@workflowTasksActivities" @bind-Value="Order.WorkflowTasksActivityId">

                            <DropDownListFieldSettings Text="DisplayName" Value="Id"></DropDownListFieldSettings>

                        </SfDropDownList>

                    }


1 Reply

SP Sureshkumar P Syncfusion Team November 14, 2022 10:44 AM UTC

Hi Alex,

Since we have already internally confirmed the data source value as null, there is no need to examine it manually. However, our component accepts a null datasource value. Therefore, when the data source value is null, our component doesn't throw any error and the popup doesn't display any data.

Regards,

Sureshkumar P


Loader.
Live Chat Icon For mobile
Up arrow icon