You can also convert the XML to serialize object and bind it to grid view.
XML Content
<countries>
<country>
<name>Teacher</name><code>12</code><size>945 amp</size>
</country>
<country>
<name>Sir</name><code>22</code><size>2456 amp</size>
</country>
</countries>
1.Drag a GridView component from the Toolbox.
2.Add to your GridView a PreRender event.
3.Write your code (see below) to bind a DataSet to the GridView.
public partial class _Default : System.Web.UI.Page
{
protected void MyGridView_PreRender(object sender, EventArgs e)
{
// Creates a DataSet and loads it with an Xml Content
DataSet aDataSet = new DataSet();
aDataSet.ReadXml(new StringReader(aXmlDoc.OuterXml));
// Bind the DataSet to the grid view
GridView gv = (GridView)sender;
gv.DataSource = aDataSet;
gv.DataBind();
}
}
Best Regards,
VG
www.TeacherJi.com
Subhadip, if this helps please login to Mark As Answer. | Alert Moderator