Velocity Reviews

Velocity Reviews (
-   ASP .Net Datagrid Control (
-   -   Bound DataGrid using nested XML (

Christopher Jedlicka 11-09-2003 05:17 PM

Bound DataGrid using nested XML

I am trying to use a datagrid control to display hierarchical data in
a flat format essentially in a master-detail relationship. i.e.

<Customer CustomerName="Customer1">
<Order OrderNumber="1">
<Item ItemName="Item1"></Item>
<Item ItemName="Item2"></Item>
<Order OrderNumber="2">
<Item ItemName="Item3"></Item>
<Item ItemName="Item4"></Item>
<Customer CustomerName="Customer2">
<Order OrderNumber="3">
<Item ItemName="Item1"></Item>
<Item ItemName="Item2"></Item>

When I load the xml data into the dataset, .NET creates the
relationships for me. My confusion happens when I bind this data to
my datagrid. I have set AutoGenerateColumns to false and manually
added each column. I can't seem to figure out how to set the
DataField for relational columns. i.e.

DataSet ds = new DataSet();
DataGrid dg = new DataGrid();
BoundColumn colCustomerName = new BoundColumn();
BoundColumn colOrderNumber = new BoundColumn();
BoundColumn colItemName = new BoundColumn();

ds.ReadXml("Data.xml", XmlReadMode.InferSchema);

colCustomerName.DataField =
colOrderNumber.DataField =
colItemName.DataField =

dg.DataSource = ds;

I tried to build in the relationships by doing this a little bit
different, but this didn't seem to work either:

colCustomerName.DataField =
colOrderNumber.DataField =
colItemName.DataField = "ItemName";

dg.DataSource = ds;
dg.DataMember = "Item";

How do I have to reference the DataSource and DataField properties to
display this relational data? I'd be especially grateful for any
assistance. Thanks.


All times are GMT. The time now is 02:23 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.