467,161 Members | 1,023 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

Best practice for combining typed DataTables for display in GridView

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
Nov 1 '07 #1
  • viewed: 3824
Share:
2 Replies
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" <j0**@newsgroups.nospamwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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


Nov 1 '07 #2
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" <RE**************************@mMvVpPsS.orgwrote in
message news:u5*************@TK2MSFTNGP05.phx.gbl...
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" <j0**@newsgroups.nospamwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>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



Nov 1 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by D Witherspoon | last post: by
2 posts views Thread by Sarmatia@gmail.com | last post: by
3 posts views Thread by cbrown@duclaw.com | last post: by
1 post views Thread by Artificer | last post: by
12 posts views Thread by BillE | last post: by
1 post views Thread by =?Utf-8?B?U0g=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.