473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DataRelations and GridView

Hello everybody,

I'm using some gridviews with datalists inside template columns.
Now, for each datalist I'm calling a method returning a dataset (depending
from a column from the gridview).

But I was wondering: is there a way to bring just one DataSet with two
related tables and apply the "child" table to the datalist?

I didn't find some examples of how to use DataRelations, so if anybody could
give me a hint... =/

Tnx!!!
Mar 30 '06 #1
3 4281
Data relations are used like below

dstInvoicesAndDetails.Tables.Add(tblInvoices);
dstInvoicesAndDetails.Tables.Add(tblInvoiceDetails );
drlInvoicesAndDetails = new DataRelation("InvoicesAndDetials",
tblInvoices.Columns["invoice"], tblInvoiceDetails.Columns["invoice"]);
dstInvoicesAndDetails.Relations.Add(drlInvoicesAnd Details);

It adds two DataTables to a data set, The master table, Invoices, which
just contains invoice number date, customer code etc. and invoice details
which contains the products, price, qty on the invoice along with the realted
invoice number.

then a command like

DataRow[]
drwInvoiceDetailsSubset=tblInvoices.Rows[1].GetChilRows(drlInvoicesAndDetails);

would return an array of datarow objects (ie. rows) that that represent the
invoice details records for row 1 in the invoice table. The datarow array
can then be bound to a control.

"Carlos Albert" wrote:
Hello everybody,

I'm using some gridviews with datalists inside template columns.
Now, for each datalist I'm calling a method returning a dataset (depending
from a column from the gridview).

But I was wondering: is there a way to bring just one DataSet with two
related tables and apply the "child" table to the datalist?

I didn't find some examples of how to use DataRelations, so if anybody could
give me a hint... =/

Tnx!!!

Mar 30 '06 #2
Tnx for the explanation!

Would you know if is possible to apply it to, for example, a nested
gridview? (that cannot be accesed from the codebehind)

"clickon" <cl*****@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
Data relations are used like below

dstInvoicesAndDetails.Tables.Add(tblInvoices);
dstInvoicesAndDetails.Tables.Add(tblInvoiceDetails );
drlInvoicesAndDetails = new DataRelation("InvoicesAndDetials",
tblInvoices.Columns["invoice"], tblInvoiceDetails.Columns["invoice"]);
dstInvoicesAndDetails.Relations.Add(drlInvoicesAnd Details);

It adds two DataTables to a data set, The master table, Invoices, which
just contains invoice number date, customer code etc. and invoice details
which contains the products, price, qty on the invoice along with the
realted
invoice number.

then a command like

DataRow[]
drwInvoiceDetailsSubset=tblInvoices.Rows[1].GetChilRows(drlInvoicesAndDetails);

would return an array of datarow objects (ie. rows) that that represent
the
invoice details records for row 1 in the invoice table. The datarow array
can then be bound to a control.

"Carlos Albert" wrote:
Hello everybody,

I'm using some gridviews with datalists inside template columns.
Now, for each datalist I'm calling a method returning a dataset
(depending
from a column from the gridview).

But I was wondering: is there a way to bring just one DataSet with two
related tables and apply the "child" table to the datalist?

I didn't find some examples of how to use DataRelations, so if anybody
could
give me a hint... =/

Tnx!!!

Mar 31 '06 #3
Hi,

If I understood your problem clearly, you can solve your problem like that.

For a nested gridview you can get use gridview ItemDataBound methods to bind
the inside grid. You must get the template column and cast it to a gridview
then bound it. And when you want to get inside gridview data's, first you
must get outside gridview's row's then get the templatecolumn then cast it
to gridview then you can access the inside gridview.

Have a good work,

Aytaç ÖZAY
Software Developer

"Carlos Albert" <nospam@noplace> wrote in message
news:OY***************@TK2MSFTNGP12.phx.gbl...
Tnx for the explanation!

Would you know if is possible to apply it to, for example, a nested
gridview? (that cannot be accesed from the codebehind)

"clickon" <cl*****@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
Data relations are used like below

dstInvoicesAndDetails.Tables.Add(tblInvoices);
dstInvoicesAndDetails.Tables.Add(tblInvoiceDetails );
drlInvoicesAndDetails = new DataRelation("InvoicesAndDetials",
tblInvoices.Columns["invoice"], tblInvoiceDetails.Columns["invoice"]);
dstInvoicesAndDetails.Relations.Add(drlInvoicesAnd Details);

It adds two DataTables to a data set, The master table, Invoices, which
just contains invoice number date, customer code etc. and invoice
details
which contains the products, price, qty on the invoice along with the
realted
invoice number.

then a command like

DataRow[]
drwInvoiceDetailsSubset=tblInvoices.Rows[1].GetChilRows(drlInvoicesAndDetails);

would return an array of datarow objects (ie. rows) that that represent
the
invoice details records for row 1 in the invoice table. The datarow
array
can then be bound to a control.

"Carlos Albert" wrote:
Hello everybody,

I'm using some gridviews with datalists inside template columns.
Now, for each datalist I'm calling a method returning a dataset
(depending
from a column from the gridview).

But I was wondering: is there a way to bring just one DataSet with two
related tables and apply the "child" table to the datalist?

I didn't find some examples of how to use DataRelations, so if anybody
could
give me a hint... =/

Tnx!!!





Apr 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Les | last post by:
I have a problem getting Dataset.WriteXml() to create a nested xml realtionship. All I get is an inline xsd (all nodes are children of the root). Documentation says to use...
3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
0
by: Randy | last post by:
I have two DataTables in a DataSet. I create a DataRelation between two like-typed columns in the first and second tables, and it works exactly as expected. Unfortunately, the default behavior...
1
by: Fleckman | last post by:
I have a DataSet with 14 DataTables and 18 Relationships that were defined within Visual Studio .NET 2003. Everything looks OK in the visual development environment, i.e. when I preview the DataSet...
0
by: George Durzi | last post by:
I have a DataSet with 3 tables, and two DataRelations dsSubs.Tables.TableName = "Subscriptions" dsSubs.Tables.TableName = "AccountManagers" dsSubs.Relations.Add "AccountManagers_Subscriptions",...
6
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
0
by: Vajrala Narendra | last post by:
hi all, am working in asp.net i am using two data entry screens for parent and child tables. i heard that using datarelations we can achieve this using single screen. is it ppossible? please...
3
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...

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.