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

Best practice for combining typed DataTables for display in GridView

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.