DataRelations and GridView

C

Carlos Albert

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!!!
 
G

Guest

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(drlInvoicesAndDetails);

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.
 
C

Carlos Albert

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 said:
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(drlInvoicesAndDetails);

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 said:
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!!!
 
A

Aytaç ÖZAY

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 said:
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 said:
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(drlInvoicesAndDetails);

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 said:
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!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top