Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2225
Issue with filtering columns with NULL values.
posted

I have a grid that has filtering enabled. It works great on most columns, but if the column has a NULL value anywhere, it throws an exception.

I can duplicate this using the sample here:

https://es.infragistics.com/community/blogs/b/taz_abdeali/posts/asp-net-mvc-3-entity-framework-infragistics-jquery-grid

Add a new customer to the Northwind database, but leave some values null.

Then, modify the controller action to look like this:

         [GridDataSourceAction]
        public ActionResult CustomerList()
        {
            List<Customer> ItemList = MVC3EntityFramework.Models.CustomerModel.GetCustomerList().ToList<Customer>();
            return View(ItemList.AsQueryable<Customer>());
        }

This will cause an error when you try to filter by any of the columns that have a NULL value. You can filter by columns that do not have NULL's just fine.

If you don't use the list and simply do this, it works:

return View(MVC3EntityFramework.Models.CustomerModel.GetCustomerList());

However, in my production code, I'm using a list then returning the list as an IQueriable (similar to above).

Any ideas?

Thanks,
Tony