How to display xml data in to a Grid or table in a ASp.net Page.
when click on linkbutton display data.
How to display xml data in to a Grid or table in a ASp.net Page.
when click on linkbutton display data.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Jun 26, 2014, 2:27 AM EDT
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Display_xmlfile_gridview_datatable
{
public partial class _Default : System.Web.UI.Page
{
protected void btn_showdata_Click(object sender, EventArgs e)
{
string Path = Server.MapPath("Data.xml");
DataTable dt = new DataTable("student");
dt.Columns.Add("sid", typeof(System.String));
dt.Columns.Add("sname", typeof(System.String));
dt.Columns.Add("saddress", typeof(System.String));
dt.Columns.Add("smarks", typeof(System.String));
dt.ReadXml(Path);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
Data.xml file