Reputation: 3448
I am working on a dataset with has several records in it and I have a method which accepts a datatable as an input parameter.
For example, I have a dataset named dsDetails
and one of the table in it is Charges
with the following data
Type Rate Name
B 14 bbb
A 10 ABC
C 12 ccc
I am passing the above datatable to my c# method as follows
Populate(dsDetails.Tables["Charges"]);
Everything looks fine, but now that I want to filter the above datatable by type and want to pass the datatable with records of Type=A
May I know good way to do that to pass a filtered datatable?
Upvotes: 1
Views: 1427
Reputation: 81675
You probably want to use a DataView object for that:
DataView dv = new DataView(dsDetails.Tables["Charges"]);
dv.RowFilter = "Type = 'A'";
Populate(dv.ToTable());
Upvotes: 2