blogspot visit counter

Saturday, 12 October 2013

How to get xml data into grid view in

How to get xml data into grid view
Introduction :- In this article i have explain how to show XML file data in grid-view .

Description :- In  my previous post i have explained How to Generating XML file From MySQL database 
Create and read XML file in , Read data from XML file in , now i have explain how to show XML file data in grid view  using

Step 1 :- Create a new web site.
Step 2:- Add a new page in your project and give the name to the page gridxml.aspx..
Step 3 :- Add  one xml file and write something like this which you want to show on gridview page of as show below.

Note  - This is a Employees.xml file already exist in your project.

<?xml version="1.0" standalone="yes"?>
    <CompanyName>abc informatics</CompanyName>
    <ContactName>chintu </ContactName>
    <CompanyName>Y N Info</CompanyName>
    <Address>Boriwali east</Address>
    <CompanyName>Gold Main</CompanyName>
    <CompanyName>Yeswant Niwas</CompanyName>
    <Address>345 Alock Nagar</Address>
    <Address>79879 JKJK</Address>
    <ContactTitle>New Dehli</ContactTitle>
    <CompanyName>Sumo tech</CompanyName>
    <Address>656 FFH</Address>

 Step 4 :- open the gridxml.aspx file and write the code as show below.

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

public partial class CS : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        if (!this.IsPostBack)

    private void BindGrid()
        using (DataSet ds = new DataSet())
            GridView1.DataSource = ds;

    protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
        GridView1.PageIndex = e.NewPageIndex;

Note -: Source code also available in

Download sample code attached

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...