473,795 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4308
Data relations are used like below

dstInvoicesAndD etails.Tables.A dd(tblInvoices) ;
dstInvoicesAndD etails.Tables.A dd(tblInvoiceDe tails);
drlInvoicesAndD etails = new DataRelation("I nvoicesAndDetia ls",
tblInvoices.Col umns["invoice"], tblInvoiceDetai ls.Columns["invoice"]);
dstInvoicesAndD etails.Relation s.Add(drlInvoic esAndDetails);

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[]
drwInvoiceDetai lsSubset=tblInv oices.Rows[1].GetChilRows(dr lInvoicesAndDet ails);

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*****@discus sions.microsoft .com> wrote in message
news:E2******** *************** ***********@mic rosoft.com...
Data relations are used like below

dstInvoicesAndD etails.Tables.A dd(tblInvoices) ;
dstInvoicesAndD etails.Tables.A dd(tblInvoiceDe tails);
drlInvoicesAndD etails = new DataRelation("I nvoicesAndDetia ls",
tblInvoices.Col umns["invoice"], tblInvoiceDetai ls.Columns["invoice"]);
dstInvoicesAndD etails.Relation s.Add(drlInvoic esAndDetails);

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[]
drwInvoiceDetai lsSubset=tblInv oices.Rows[1].GetChilRows(dr lInvoicesAndDet ails);

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******** *******@TK2MSFT NGP12.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*****@discus sions.microsoft .com> wrote in message
news:E2******** *************** ***********@mic rosoft.com...
Data relations are used like below

dstInvoicesAndD etails.Tables.A dd(tblInvoices) ;
dstInvoicesAndD etails.Tables.A dd(tblInvoiceDe tails);
drlInvoicesAndD etails = new DataRelation("I nvoicesAndDetia ls",
tblInvoices.Col umns["invoice"], tblInvoiceDetai ls.Columns["invoice"]);
dstInvoicesAndD etails.Relation s.Add(drlInvoic esAndDetails);

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[]
drwInvoiceDetai lsSubset=tblInv oices.Rows[1].GetChilRows(dr lInvoicesAndDet ails);

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
3486
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 Dataset.Relations.Nested="true"; but this doesn't produce the nested xml as it should. I have even used a unit test, "MessageBox.Show(Dataset.Relations.Nested.ToString());". I get the "True" as an answer. So, the ReationsCollection has a relation and it is nested....
3
5677
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 GridView to allow entry of quantity and Y/N switch for
0
1186
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 seems to be that the link (or links if there's multiple DataRelations) are all under the left-most column. Is there any way to put the link under the column being linked? Thanks... Randy
1
1910
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 all the relationship appear correctly defined. However, when I create a new DataSet of this type within my project I only see two of the DataRelations in the DataSet.Relations collection. I don't know where else to look to trouble shoot the...
0
1447
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", dsSubs.Tables.Columns dsSubs.Tables.Columns) dsSubs.Tables.TableName = "NewsFeeds"
6
3041
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 current_row_key of Grid1... to the objectDataSource2 parameter? (so that the second grid, gets only the information to do with current row of grid1)
5
4840
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 automatically if the data doesn't change. But if records have been added or deleted then it looks as if some code is necessary: I've done this by using GridView.SelectedValue to get the key value of the currently selected Row and then by itterating...
0
983
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 suggest how? Thanks inAdvance.
3
5246
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 DataTable, I am using List of Objects. Here's one example: http://ryanolshan.com/technology/gridview-without-datasourcecontrol-datasource/
0
10436
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.