473,581 Members | 2,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
2 4117
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**@newsgroup s.nospamwrote in message
news:%2******** ********@TK2MSF TNGP05.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.orgwro te in
message news:u5******** *****@TK2MSFTNG P05.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**@newsgroup s.nospamwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>Hi

I need to search a number of DataTables within a DataSet (with some
relationship s) 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

136
9279
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to...
18
2835
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
2
1127
by: Sarmatia | last post by:
I have a table of ID vaules that are related to lookup tables. I created a DataAccess component from wich the ObjectDataSource gets a typed datatable. A GridView is bound to that ObjectDataSource and allows Edit and Delete. On the same page is the means to add a new record (since the GridView does not support that ... but that's another...
3
1804
by: cbrown | last post by:
I am rebuilding an existing application that relies on an SQL DB. The app is a scheduling/employee management program. My question pertains to best practices in dotnet and database. I use a 3 tier model and have custom classes for things like Employees. What comes to question is when I load an Employee from my DB, I populate the...
5
5897
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique CompanyID's. The second combobox will contain unique memberID's. Each of the tables that I have to search contain a CompanyID and a memberID field, and...
1
1356
by: Artificer | last post by:
I am creating an application that will have around 20 web forms. Should I create only one strongly typed dataset that includes all the DataTables required for all the forms or should I create one strongly typed dataset per web form that includes only the DataTables required by that specific form?
12
3572
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a gridview, for example, I loop through a datareader, populating an array list with instances of a custom class in the middle tier, and then send the...
3
2830
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one dataset to data in a second dataset, using a common key. I will first describe the problem in words and then I will show my code, which has most of the...
1
2579
by: =?Utf-8?B?U0g=?= | last post by:
To All, Just a guideline on the best practice for this issue. I have a number of tables in SQL, and I want to join across them and display their corresponding values in a datagrid. For example (fictitious), I have a username, and they have a country associated with them. I join User to Country (on CountryId) and want to display...
0
7808
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8312
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6564
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1410
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.