Bind data in XML to asp:DataGrid : XML DataGrid « XML « ASP.Net






Bind data in XML to asp:DataGrid

<%@ Page language="c#" %>
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Xml" %>

<script language="c#" runat="server">
  void Page_Load()
  { 
//    string xmlFilename = @"C:\artists.xml";
    string xmlFilename = MapPath("AdRotatorBasic.xml");
    DataSet newDataSet = new DataSet(); 
    newDataSet.ReadXml(xmlFilename);
    DataGrid1.DataSource = newDataSet;
    DataGrid1.DataBind();
  }
</script>

<html>
  <head>
    <title>Data Grid Control example</title>
  </head>
  <body>
    <asp:DataGrid id="DataGrid1" runat="server"  />
  </body>
</html> 

           
       








Related examples in the same category

1.Bind XML file to DataSet and bind to asp datagrid
2.Read xml data and bind to datagrid in C#
3.DataSet read XML data and bind to asp datagrid
4.Load XML to asp:DataGrid