.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Bind a Xml file data to Gridview

Posted By:Sanjeeb Lenka       Posted Date: November 26, 2013    Points: 200    Category: ASP.NET    URL: http://www.dotnetspark.com  

In this article i will show how to bind a Xml file data to Grid view in Asp.net.

In this article i will show how to bind a Xml file data to Grid view in Asp.net.

First create a a xml file like following file:

<?xml version="1.0" encoding="utf-8" ?>
Add a page to the website and add a grid to the page .

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <form id="form1" runat="server">
        <asp:GridView ID="GridView1" runat="server">

then write the following code in .cs:

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 _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        DataSet ds = new DataSet();
        GridView1.DataSource = ds.Tables[0];

now build the website . it will bind the xml file data to gridview..

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend