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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Jun 26, 2014, 6:27 AM
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