Q:

Using LINQ query result for data source for GridControl c#

I have a function like this in a static class
public static IEnumerable<MyObject> getFilteredList(int docType)
{
    var fItems = from i in list
                 where i.DocType == docType
                 select i;

    return fItems;
}

When I use this returned list for a data source to my Grid in the form like this for example:
GridControl.DataSource = staticClass.getFilteredList(10)

The Grids DataSource property is null. Can you explain me why this is happening ?
Edit: the list variable is List which contains elements with DocType = 10.
The Items contains elements.

A:

You should use
GridControl.DataSource = staticClass.getFilteredList(10).ToList();

to create a new List instance to bind to your grid.
Another way is to use a BindingList, which fully supports databinding and gives you usefull events like ListChanged and AddingNew.
var list = new BindingList(staticClass.getFilteredList(10).ToList());

GridControl.DataSource = list;

