Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I want to display xml data into grid view can u guide or send any snippets
Posted

http://www.dotnetheaven.com/UploadFile/prathore/DataGridView09122007013411AM/DataGridView.aspx[^]

Sample Code..
private void Form_Load(object sender, EventArgs e)
     {
         XmlDataDocument xmlDatadoc = new XmlDataDocument();
         xmlDatadoc.DataSet.ReadXml("C:\\path.xml");
         DataSet ds = new DataSet("Sample");
         ds = xmlDatadoc.DataSet;
         dataGridView1.DataSource = ds.DefaultViewManager;
         dataGridView1.DataMember = "Sample";
     }
 
Share this answer
 
Hi,
Try this code:
C#
DataSet ds=new DataSet();
ds.ReadXml(Server.MapPath("people.xml"));
Grid1.DataSource=ds;
Grid1.DataBind();

http://www.dotnetfunda.com/forums/thread6541-display-xml-data-from-xml-in-gridview.aspx[^]
 
Share this answer
 
Comments
vinothkumaran1988 3-Sep-12 4:45am    
XmlTextReader readxml = new XmlTextReader(Server.MapPath("testxml.xml"));
DataSet ds = new DataSet();
ds.ReadXml(readxml);
readxml.Close();
if (ds.Tables.Count != 0)
{
GridView1.DataSource = ds;
GridView1.DataBind();

}

http://shamjeet.blogspot.in/p/aspnet.html#r2
C#
DataSet ds = new DataSet();
      try
      {
          ds.ReadXml(Server.MapPath("XMLfilename.xml"));
          if (ds != null && ds.HasChanges())
          {
              Gridview1.DataSource = ds;
              Gridview1.DataBind();
          }
          else
          {
              Gridview1.DataBind();
          }
      }
      catch (Exception ex)
      {
      }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900