Filtering in BindingSource of a generic List
-
I need to have a databinding of List or anything .. I have SQL SErver and a functions which returns List from Database.. Now if I am doing like this: BindingSource src = new BindingSource(); src.DataSource = Book.GetList(); //A Getlist function from Book class returning the list object. datagridview1.DataSource = src; Everything works fine.. But if I need to filter the bindingsource , I know we have a filter property like this. src.Filter = "Author = " + anything.ToString(); But this is not working... But if I am having a DataSource of DataTable having a table of Book . . ie. . if I write.. src.DAtaSource = Book.GetTable(); Everything goes fine .. But on List it doesnt work properly . . Can anyone help me out ???
-
I need to have a databinding of List or anything .. I have SQL SErver and a functions which returns List from Database.. Now if I am doing like this: BindingSource src = new BindingSource(); src.DataSource = Book.GetList(); //A Getlist function from Book class returning the list object. datagridview1.DataSource = src; Everything works fine.. But if I need to filter the bindingsource , I know we have a filter property like this. src.Filter = "Author = " + anything.ToString(); But this is not working... But if I am having a DataSource of DataTable having a table of Book . . ie. . if I write.. src.DAtaSource = Book.GetTable(); Everything goes fine .. But on List it doesnt work properly . . Can anyone help me out ???
I'm just getting into the List stuff as well, looks like you need to write your own filtering methods. Look into List.FindAll. I'm still to be convinced a List<> is better than a datatable/view for this stuff. Ah well research, it's what keeps us interested!
Never underestimate the power of human stupidity RAH
-
I'm just getting into the List stuff as well, looks like you need to write your own filtering methods. Look into List.FindAll. I'm still to be convinced a List<> is better than a datatable/view for this stuff. Ah well research, it's what keeps us interested!
Never underestimate the power of human stupidity RAH
Yes It's preety fine to work with list. . As it can be handled very easily. And also It can be easily used in 3 tier architecture. Regarding the filtering of list , Actually list can be filtered using LINQ. It can be done something like this; var result = from p in lststudents where p.FirstName = 'Jay' select p; This works fine. But I am more precisely talking about the filtering of Binding source. It works with datatable , but not with List.. Anyway thanx for your concern. .