Best practice for combining typed DataTables for display in GridView

Discussion in 'ASP .Net' started by J055, Nov 1, 2007.

  1. J055

    J055 Guest

    Hi

    I need to search a number of DataTables within a DataSet (with some
    relationships) and then display the filtered results in a GridView. The
    Columns that need to be displayed come from 2 of the tables but the search
    needs check 3 or 4 tables. Do I need to create a new DataTable which has the
    columns from both the tables so I can display in the Gridview or can I get
    the columns somehow from the DataSet without creating a new table?

    I feel like I'm missing something when it comes to getting the benefits of
    DataTable relationships in terms of combining them for display in a flat
    GridView.

    Any ideas suggestions, pointers to examples would be appreciated.

    Thanks
    Andrew
     
    J055, Nov 1, 2007
    #1
    1. Advertising

  2. The simple answer is make another table.

    GridView gets data from a datasource. Datasource is an object. Two tables
    are two objects. You have to make one single object out of columns you need
    and databind to it. An obvious way is to make another DataTable, but there
    could be reasons for choosing different classes.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin


    "J055" <> wrote in message
    news:%...
    > Hi
    >
    > I need to search a number of DataTables within a DataSet (with some
    > relationships) and then display the filtered results in a GridView. The
    > Columns that need to be displayed come from 2 of the tables but the search
    > needs check 3 or 4 tables. Do I need to create a new DataTable which has

    the
    > columns from both the tables so I can display in the Gridview or can I get
    > the columns somehow from the DataSet without creating a new table?
    >
    > I feel like I'm missing something when it comes to getting the benefits of
    > DataTable relationships in terms of combining them for display in a flat
    > GridView.
    >
    > Any ideas suggestions, pointers to examples would be appreciated.
    >
    > Thanks
    > Andrew
    >
    >
     
    Eliyahu Goldin, Nov 1, 2007
    #2
    1. Advertising

  3. J055

    J055 Guest

    Thanks Eliyahu

    That's kind of what I was coming round to thinking. If I create a DataTable
    without a TableAdapter then I can populate it with the data I need from the
    results search and hopefully without too much extra typing!

    Thanks again
    Andrew


    "Eliyahu Goldin" <> wrote in
    message news:...
    > The simple answer is make another table.
    >
    > GridView gets data from a datasource. Datasource is an object. Two tables
    > are two objects. You have to make one single object out of columns you
    > need
    > and databind to it. An obvious way is to make another DataTable, but there
    > could be reasons for choosing different classes.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    >
    >
    > "J055" <> wrote in message
    > news:%...
    >> Hi
    >>
    >> I need to search a number of DataTables within a DataSet (with some
    >> relationships) and then display the filtered results in a GridView. The
    >> Columns that need to be displayed come from 2 of the tables but the
    >> search
    >> needs check 3 or 4 tables. Do I need to create a new DataTable which has

    > the
    >> columns from both the tables so I can display in the Gridview or can I
    >> get
    >> the columns somehow from the DataSet without creating a new table?
    >>
    >> I feel like I'm missing something when it comes to getting the benefits
    >> of
    >> DataTable relationships in terms of combining them for display in a flat
    >> GridView.
    >>
    >> Any ideas suggestions, pointers to examples would be appreciated.
    >>
    >> Thanks
    >> Andrew
    >>
    >>

    >
    >
     
    J055, Nov 1, 2007
    #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. Kevin Spencer

    Re: Combining DataTables

    Kevin Spencer, Jul 21, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,113
    Kevin Spencer
    Jul 21, 2003
  2. Ersin Gençtürk
    Replies:
    1
    Views:
    3,522
    Ersin Gençtürk
    Oct 6, 2004
  3. Bauhaus
    Replies:
    0
    Views:
    432
    Bauhaus
    May 10, 2008
  4. Mikaël PLOUHINEC

    Problem display several DataTables with relations

    Mikaël PLOUHINEC, Dec 21, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    685
    Mikaël PLOUHINEC
    Dec 21, 2006
  5. Kjell Kristiansson
    Replies:
    0
    Views:
    299
    Kjell Kristiansson
    Nov 30, 2005
Loading...

Share This Page