473,401 Members | 2,127 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,401 software developers and data experts.

How to access Child table data within a windows form datagrid


Hi All,

I am trying to acess the rows within a child table of a windows form
datagrid. I have tried using the CurrencyManager & BindingManagerBase
to get the data but doesn't work.

The problem is that when trying to retrive a row from a childtable in a
datagrid using either objects it still retrieves the parents data. I
want the selected childtable row data.

My XML:
<Customers id="123" name="Joe" level="A">
<Orders id="1234" date="2004-04-02" level="A"/>
<Orders id="1236" date="2004-04-02" level="B"/>
<Orders id="1233" date="2004-04-02" level="C"/>
</customers>
<Customers id="098" name="Mike" level="A">
<Orders id="1274" date="2004-04-02" level="A"/>
<Orders id="1276" date="2004-04-02" level="B"/>
<Orders id="1203" date="2004-04-02" level="C"/>
</customers>
<Customers id="757" name="Pat" level="A">
<Orders id="1433" date="2004-04-02" level="A"/>
<Orders id="1432" date="2004-04-02" level="B"/>
<Orders id="1421" date="2004-04-02" level="C"/>
</customers>

The dataset is directly populated with the XML.
No Datarelations are manually created.

DataView view = _ds.Tables[ "Customers" ].DefaultView;

foreach(DataTable dTable in _ds.Tables)
{
DataGridTableStyle dgStyle = new DataGridTableStyle();
dgStyle.MappingName = dTable.TableName;
dataGrid1.TableStyles.Add(dgStyle);
dataGrid1.TableStyles[ dTable.TableName ].AllowSorting = false;
}

dataGrid1.DataSource = view;

CurrencyManager _cm =
(CurrencyManager)BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember];
BindingManagerBase _bm = BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember];
The code in a buttonclick event.
It is suppose to get the orders ID & Level, but it gets the parents
instead. :(

//Using BindingManagerBase
string selectedCustomer =
((DataRowView)_bm.Current).Row["level"].ToString();
string selectedID = ((DataRowView)_bm.Current).Row["id"].ToString();

//Using CurrencyManager

DataRowView dr = (DataRowView)_cm.Current;
string selectedCustomer = dr["level"].ToString();
string selectedID = dr["id"].ToString();
Any help?

Lanky

Nov 16 '05 #1
0 1363

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

Similar topics

2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
0
by: lanky_tx | last post by:
Hello, I am trying to hide a column in a child table within a windows form DataGrid control. I am populating the Datagrid datasource with an dataset which is populated with hierarchical XML...
3
by: Quetzal | last post by:
Hello, I have a dataset populated using an XML file. The schema has hierarchical components. Let's say <a><b></b></a>. I have created a datagrid and I have assigned a datastyle and then...
0
by: Ross | last post by:
ASP.NET Problem: I have a dataset with a parent table and a child table. For every row in the parent table there are ~1/2 dozen corresponding records in the child table. In the ASPX page I have a...
7
by: Neo Geshel | last post by:
Greetings. I have a serious problem. I have multiple sets of tables, several of which are chained more than two tables deep. That is, I have a parent, a child, and a great-grandchild table. ...
11
by: CM Manager via DotNetMonster.com | last post by:
I am very frustrated due to this exception error I am receiving. I've tried searching numerous user support groups, Microsoft Support Net, Google, etc. and haven't found exactly my situation....
13
by: mfreeman | last post by:
The minimal code (VB.NET 2003) needed to show this problem is shown below. All I do is loop through the records in the table and update them without making any changes. Out of 600 records, about...
2
by: Frav | last post by:
The Reps team have been experiencing that Access 2002 unexpectedly quits while working and also lots of Corruption Failures and "Record lock can not update" messages since the upgrade from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
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...
0
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...
0
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...

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.