Hi,
I'm trying to create an example of HierachicalWebDataGrid using xml data but it doesn't work.
i followed this example . But the page is blanc.
Hello heni86_2003 ,
Please refer to the attachment. Therein you’ll find working samples of those two scenarios.
Let me know if you have any questions regarding them.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
Tahnk you Maya, it work correctly.
So, i have two others question please.
1/ for the last example how can do this with C#
I tried with this Code
BoundDataField boundField = new BoundDataField(true);
boundField.Key = "CategoryID";
boundField.Header.Text = "Category ID";
boundField.DataFieldName = "CategoryID";
this.WebHierarchicalDataGrid1.Columns.Add(boundField);
Band childBand = new Band();
childBand.DataKeyFields = "ProductID";
childBand.DataMember = "Product";
this.WebHierarchicalDataGrid1.Bands.Add(childBand);
// Define column for the child band
boundField = new BoundDataField(true);
boundField.Key = "ProductID";
boundField.Header.Text = "Product ID";
boundField.DataFieldName = "ProductID";
this.WebHierarchicalDataGrid1.Bands["Product"].Columns.Add(boundField);
but i have this error:
Line 53: boundField.DataFieldName = "ProductID"; Line 54: Line 55: this.WebHierarchicalDataGrid1.Bands["Product"].Columns.Add(boundField);
2/ How can i do it with an XML File like this?
<Item><Category>2- category 2</Category><Title>title 21</Title><Key>A5</Key></Item>
I tried it with this code but it doesn't work:
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Model.xml" XPath="/ItemList/Item"></asp:XmlDataSource>
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server"
AutoGenerateBands="False" AutoGenerateColumns="False"
DataSourceID="XmlDataSource1" Key="Category">
<Columns>
<ig:BoundDataField DataFormatString="Category" Key="Category" Header-Text="Category" />
</Columns>
<Bands>
<ig:Band AutoGenerateColumns="False" DataMember="Title" DataKeyFields="Title">
<ig:BoundDataField DataFieldName="Title" Key="Title" Header-Text="Title" />
<ig:BoundDataField DataFieldName="Key" Key="Key" Header-Text="Key" />
</ig:Band>
</Bands>
</ig:WebHierarchicalDataGrid>
There seems to be a slight mismatching between the xml file and the mark up in the sample so if you try and copy this code directly into a solution it would not work. First off the XPath should look like this:”XPath="/Categories/Category" “ since an element with the name NewDataSet doesn’t exist in that xml file. Also for the bands the DataMember property should match an element from the xml file. So for the sibling band 1 the DataMember should be DataMember="Product" and so on. Please refer to the attachment for a working sample.