How to fill Grid from XML file ?


For doing this task create a Emp.xml file like this

<?xml version=”1.0″ encoding=”utf-8″?>
<Emp Id=”1″>
<Emp Id=”2″>
<Emp Id=”3″>

Step2: Write the code in Code behind file like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class GridFillXML : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
string filePath = Server.MapPath(“Emp.xml”);
using (DataSet ds = new DataSet())
GridView1.DataSource = ds;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.