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 *

3 + 5 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">