Read XML file and Bind to DataGrid in ASP.Net.

Bind XML file to DataGrid

  • C# .Net

        DataSet DS = new DataSet();
        DS.ReadXml(Server.MapPath("meeraacademy.xml"));
        DataGrid1.DataSource = DS.Tables[0].DefaultView;
        DataGrid1.DataBind();


    Create a meeraacademy.xml file.

    "1">    
          Meera
          Vasani 
          Modasa

      
    Student >
      <
    Student id="2">    
          Rahul
          Patel
          Bombay
     
    Student >

     

  • Vb.Net

    Dim Ds as New DataSet
    DS.ReadXML(Mappath("meeraacademy.xml"))
    DataGrid1.DataSource=DS
    DataGrid1.DataBind()


Leave a Reply

Your email address will not be published. Required fields are marked *

five × four =