Reputation: 265
My XML is in following format.
<Test1>
<Test>
<Name>A</Name>
<Image>~/FltImages/DL.gif</Image>
<Fare>1243.8</Fare>
<OutbondInfo>
<Duration>0900</Duration>
<Type>Non-Stop</Type>
<Sector>
<Name>A</Name>
<Image>~/FltImages/DL.gif</Image>
<No>4410</No>
<AirCraftNo>744</AirCraftNo>
<CabinClass Name="ECONOMY">M</CabinClass>
</Sector>
</OutbondInfo>
<InboundInfo>
<Duration>0805</Duration>
<Type>Non-Stop</Type>
<Sector>
<Name>A</Name>
<Image>~/FltImages/DL.gif</Image>
<No>4410</No>
<AirCraftNo>744</AirCraftNo>
<CabinClass Name="ECONOMY">M</CabinClass>
</Sector>
</InboundInfo>
<Type>IT</Type>
</Test>
</Test1>
I am reading the detail as follows, but my code doesn't read the code under OutbondInfo and InbondInfo. How can I read data under those tags and save in same DataSet as shown in code below.
XmlNode xNode;
xNode = fc.gettDetail(TextBox1.Text);
DataSet ds = new DataSet();
if (xNode != null)
{
XmlTextReader xmlTextReader = new XmlTextReader(xNode.OuterXml, XmlNodeType.Element, null);
ds.ReadXml(xmlTextReader);
GridView1.DataSource = ds;
GridView1.DataBind();
}
Please Help!!
Thanks
Upvotes: 1
Views: 88
Reputation: 7943
Your DataSet is returning multiple table. You can select only one table to bind to a gridview. Here's how your DataSet looks:
Solution: For each table use separate GridView. Bind GridViews like below:
GridView1.DataSource = ds.Tables["OutbondInfo"];
GridView1.DataBind();
//Add another GridView "GridView2" in markup
GridView2.DataSource = ds.Tables["InboundInfo"];
GridView2.DataBind();
Hope it helps!
Upvotes: 1