Filtering Data in DataGrid

gooper

New member
Joined
Feb 20, 2003
Messages
1
Hi Folks

I have a problem with migrating from vb6 to vb.net

I have a DataGrid with a huge amount of data in it.
To enable myself to find somthing faster i used a Filter on the ResultSet.

env.rsCommand1.Filter= "barcode = 280tz1305" for Example
me.DataGrid1.DataMember= "Command1"

And he saw that it was fine.
;-)

But now i tryed to open my project in VS.Net and the Upgrade-wizzard makes a
Imports Microsoft.VisualBasic.Compatibility

Compatibility......hmmmmm. That is definitly not why i wanted to use .net
So I went the long way rebuilding my app in VB.net.
But when i came to the point where i wanted the filter i had a problem:
How to do a filter on the DataTable or DataSet i use to fill my DataGrid?

on the Microsoft-Page i found a page about .Select for DataTable but it returnes a DataRow Object.

How can i insert the DataRows returned from the .Select into an DataTable or DataSet?
Or is there a better way to do that?

regards
Tobi
 
I think I can help. Are you using sql server or other database. Have you created the dataset? Do you want the filter string hard coded or will you be placing a string into a textbox then clicking a button to filter the datagrid.
 
You want a DataView object. You can create one from a DataSet with something like:
C#:
DataView view = new DataView(dataSet1.Tables["Table1"], "filtercol = 4");

You can specify some pretty advanced filters, including checking for nulls and more. The DataView can also provide sorting (an optional parameter to the contructor or overloaded constructor, depending on your language :))

-Nerseus
 
Back
Top