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

Discussion in 'ASP .Net' started by Marco Ippolito, May 17, 2004.

  1. 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. :)
    Marco Ippolito, May 17, 2004
    #1
    1. Advertising

  2. 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
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, May 17, 2004
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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
    Marco Ippolito, May 19, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason
    Replies:
    1
    Views:
    487
    Jason
    Aug 31, 2004
  2. Siegfried Heintze

    Wanted: Example of Row Filtering with DataView

    Siegfried Heintze, Sep 10, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    18,991
    Juan T. Llibre
    Sep 11, 2005
  3. Anup
    Replies:
    0
    Views:
    350
  4. Anup Daware

    Filtering Dataview [Strange Problem]

    Anup Daware, Aug 8, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    4,007
    Doug Goodman
    Aug 17, 2006
  5. CodeMonkey
    Replies:
    1
    Views:
    728
    joyal jhaveri
    Feb 4, 2011
Loading...

Share This Page