NullReferenceException in RadzenDropDownDataGrid #83

Closed
opened 2026-01-29 17:31:18 +00:00 by claunia · 0 comments
Owner

Originally created by @OndrejUzovic on GitHub (Apr 12, 2021).

If AllowFilteringByAllStringColumns = true in RadzenDropDownDataGrid and some string column value is null (which is quite common if the column value is optional) then NullReferenceException is thrown.

The exception is thrown in the method RadzenDropDownDataGrid.OnLoadData(..) when query.Count() is called (line 243 in 3.2.2 version).

Here is the example code to reproduce the error:

<RadzenDropDownDataGrid TValue="string" @bind-Value="myValue" Data=@(myCustomers)
                        FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" AllowFiltering="true" AllowClear="true"
                        TextProperty="CompanyName" ValueProperty="CustomerID"
                        AllowFilteringByAllStringColumns="true">
    <Columns>
        <RadzenDropDownDataGridColumn Property="CustomerID" Title="CustomerID" Width="100px" />
        <RadzenDropDownDataGridColumn Property="CompanyName" Title="CompanyName" Width="200px" />
        <RadzenDropDownDataGridColumn Property="Optional" Title="Optional" Width="200px" />
    </Columns>
</RadzenDropDownDataGrid>

@code {
    public class Customer
    {
        public string CustomerID { get; set; }
        public string CompanyName { get; set; }
        public string Optional { get; set; }
    }

    private List<Customer> myCustomers = new List<Customer>()
    {
        new Customer() { CustomerID = "1", CompanyName = "ABC", Optional = "hello" },
        new Customer() { CustomerID = "2", CompanyName = "CDE", Optional = "hi" },
        new Customer() { CustomerID = "3", CompanyName = "EFG", Optional = null },
    };

    private string myValue;
}

Originally created by @OndrejUzovic on GitHub (Apr 12, 2021). If **AllowFilteringByAllStringColumns = true** in RadzenDropDownDataGrid **and some string column value is null** (which is quite common if the column value is optional) then NullReferenceException is thrown. The exception is thrown in the method RadzenDropDownDataGrid.OnLoadData(..) when query.Count() is called (line 243 in 3.2.2 version). Here is the example code to reproduce the error: ``` <RadzenDropDownDataGrid TValue="string" @bind-Value="myValue" Data=@(myCustomers) FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" AllowFiltering="true" AllowClear="true" TextProperty="CompanyName" ValueProperty="CustomerID" AllowFilteringByAllStringColumns="true"> <Columns> <RadzenDropDownDataGridColumn Property="CustomerID" Title="CustomerID" Width="100px" /> <RadzenDropDownDataGridColumn Property="CompanyName" Title="CompanyName" Width="200px" /> <RadzenDropDownDataGridColumn Property="Optional" Title="Optional" Width="200px" /> </Columns> </RadzenDropDownDataGrid> @code { public class Customer { public string CustomerID { get; set; } public string CompanyName { get; set; } public string Optional { get; set; } } private List<Customer> myCustomers = new List<Customer>() { new Customer() { CustomerID = "1", CompanyName = "ABC", Optional = "hello" }, new Customer() { CustomerID = "2", CompanyName = "CDE", Optional = "hi" }, new Customer() { CustomerID = "3", CompanyName = "EFG", Optional = null }, }; private string myValue; } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#83