Hello,
I followed the online documentation and have almost got the grid populating from an XML file. The problem is although the grid is finding the nodes via the DataKeyName I have set, it is not reading the child nodes of that node it has found. So I am getting 10 empty rows, which is currently the right number of Topics/XML nodes. Here is my code to try to explain further:
XML
HTML
C#
How do I bind each column to the child node (i.e. TopicName) of the node it has found (i.e. Topic). Surely it is just a case of mapping it correctly somehow?
Thanks,
Michael
I followed the online documentation and have almost got the grid populating from an XML file. The problem is although the grid is finding the nodes via the DataKeyName I have set, it is not reading the child nodes of that node it has found. So I am getting 10 empty rows, which is currently the right number of Topics/XML nodes. Here is my code to try to explain further:
XML
| <Topics> |
| <Topic TopicId="1"> |
| <TopicName>Test</TopicName> |
| <Categories> |
| <Category>Category 1</Category> |
| <Category>Category 2</Category> |
| </Categories> |
| <FileName>Test.html</FileName> |
| </Topic> |
| </Topics> |
HTML
| <telerik:RadGrid ID="gridLearningList" runat="server"> |
| <MasterTableView AutoGenerateColumns="false" DataKeyNames="TopicId"> |
| <Columns> |
| <telerik:GridBoundColumn |
| DataField="TopicName" |
| HeaderText="Learning topic"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="Categories" |
| HeaderText="Category"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn |
| DataField="FileName" |
| HeaderText="File name"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| <asp:XmlDataSource ID="dsLearningList" runat="server" /> |
C#
| private void PopulateLearningList() |
| { |
| dsLearningList.DataFile = "~/App_Data/OnlineLearningTopics.xml"; |
| gridLearningList.DataSourceID = "dsLearningList"; |
| gridLearningList.DataBind(); |
| } |
How do I bind each column to the child node (i.e. TopicName) of the node it has found (i.e. Topic). Surely it is just a case of mapping it correctly somehow?
Thanks,
Michael