I have a data table. If I set the DataSource of a DataGrid to the data table it displays all of the data just fine. However if I use a lambda expression to filter out some of the data and then reassign the datasource it does not display anything. This is what I have tried...
var AllPeople =
from r in CompanyDataTable.AsEnumerable()
select new
{
FirstName = r.Field<string>("FirstName"),
LastName = r.Field<string>("LastName"),
Gender = r.Field<string>("Gender"),
Age = r.Field<double>("Age"),
City = r.Field<string>("City"),
State = r.Field<string>("State"),
Cagegory = r.Field<string>("CategoryGroup"),
};
SomeDataGrid.DataSource = AllPeople;
This compiles just fine and runs fine too but the data grid is empty. If I pause execution after executing the lambda expression I can see taht AllPeople does contain a list of data it just donsn't get displayed. Does using AsEnumerable prevent you from using the data in a datagrid or something? How can I fix this?