priyanka
priyanka

Reputation: 553

filtering a List before binding to a DataGridView

I have created a class which has three attributes. I created a List collection of that object.

I've used that collection for filling a DataGridView. I want to filter the data from the DataGridView.

How can I filter the list collection?

Upvotes: 0

Views: 865

Answers (2)

sajoshi
sajoshi

Reputation: 2763

If it is a list collection and you are using .Net 2.0, You don't have the LINQ support. In that case one option would be do the filtering before getting the objects in the list.

i.e. You get the Data from SQL Server into a DataTable and then have multiple Dataviews (1 for each filter). From these views you can populate your list objects.

Upvotes: 0

Deepak
Deepak

Reputation: 7917

You can use generic function for it like..

List= List.FindAll(delegate(class obj) { return obj.name=="abc"; });

Here "obj" is a object of your class and the "name" is a property by which we can filter property.

Upvotes: 1

Related Questions