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

M

Marco Ippolito

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/D....asp?df=100&forumid=26257&exp=0&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. :)
 
G

Guest

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
 
M

Marco Ippolito

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 said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top