By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,024 Members | 2,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,024 IT Pros & Developers. It's quick & easy.

SQL UNION -like filtering of offline DataSet into DataView for WebControl binding

P: n/a
I have an offline DataSet:

id (PK, sorted ASC), firstname, enabled
1, Aaron, true
2, Bill, false
3, Charlie, true
....
10001, Mike, false
10002, Nathan, false

and I need to bind a DataView to a Repeater to fetch something like:

id #2 (I can think of this as a Find)
+
all records whose firstname field contains 'th' (I can think of this as a
Filter)
+
all 'enabled' records whose firstname field don't start with "Mi", in
descending order

a UNION -like query, in other words, but performed using Filtering.

I have read this good article from Hugo Flores:

http://www.codeproject.com/aspnet/Da...&select=670504

but I am still left wondering.. doesn't ADO.NET provide a built-in system of
building multiple DataRows from __DataSet filters__ into a DataView so that
the latter be bound to a Control's DataSource attribute?

The returned records can have the same structure as the ones already in the
DataSet, I don't need to drop/add columns or perform aggregate
calculations..

Anybody already wrestled with this situation? Found any elegant & performing
solutions? (of course I can code iterative data retrieval and population of
a 'new' DataTable - I guess I am looking for a way to 'add' DataViews..
perhaps extending the class and implementing a Union method... :)

Thanks for your help, I can already see this building into a long thread. :)

Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi

1. In SQL, UNIONed Results from one table or view can often be presented by concatenating multiple conditions using OR
2. In your case, as long as your results are in one datatable, you can create a dataview to filter out.
like
Dim dv as new DataView(
dv.Table = ds1.Tables(0
dv.RowFilter = "id = 2 OR firstname LIKE '*th*' OR firstname NOT LIKE 'Mi*'
dv.Sort = "firstname DESC
Then you can bind this dataview to your repeater
Hope this help

Bin Song, MCP
Nov 18 '05 #2

P: n/a
Hi Bin Song and thanks for trying to help.. I actually need a reverse sort +
condition checking on the third condition and a normal sort + condition
checking on the second one.. Best wishes, Marco

"Bin Song, MCP" <an*******@discussions.microsoft.com> wrote in message
news:F9**********************************@microsof t.com...
Hi,

1. In SQL, UNIONed Results from one table or view can often be presented by concatenating multiple conditions using OR. 2. In your case, as long as your results are in one datatable, you can create a dataview to filter out. like:
Dim dv as new DataView()
dv.Table = ds1.Tables(0)
dv.RowFilter = "id = 2 OR firstname LIKE '*th*' OR firstname NOT LIKE 'Mi*' " dv.Sort = "firstname DESC"
Then you can bind this dataview to your repeater.
Hope this helps

Bin Song, MCP

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.