Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

All,

Is it possible to have a dataview to filter out a datatable like this.

 

A datatable has 5 rows with ID 1, 2, 3, 4, 5

I want to have a dataview to filter out ID 1, 3, 4 so I can only see 2, 5.

 

Thanks

Donald DUCK : YOU ARE FIRED!!!
Posted
Will the number of the records to filter for change? If so, you may look at the possibility of using parameters as part of your SQL filter (WHERE) statement that is used to fill your dataset.
Posted

No.. not that I know of, at least!!

Yes, using SQL to filter out rows would be THE best way, however, it won't work in my case here due to some sort of business rule. So the question is still remain the same, is it possible to filter out a datatable like what I said before.

 

Many thanks!!

Donald DUCK : YOU ARE FIRED!!!
  • 2 weeks later...
Posted

yeah, referring to what PlausiblyDamp said, set your

 

dv.RowFilter property to a string such as

AssetID LIKE '*0*' AND EmployeeID LIKE '*1*' AND DepartmentID LIKE '*3*'

 

that creates a filter where the values in the columns must CONTAIN (even more powerful than EQUAL) the values '0' '1' and '3'

 

you can create some really powerful stuff...to read more about this, in your VS.NET index type this exactly "DataColumn.Expression property"

 

however be careful where those values that you're searching for come from. If it's all done programatically, it's ok, but if you accept text from the user VALIDATE it 1000 times before you pass it to your database. Read up more on SQL Injection Attacks...freaky stuff.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...