How to bind xml with grid view in c#

In this article, I will bind the gridview with xml file. Xml file is client side mark up language so its my very good way to bind the data from client side
XML File :-

<?xml version="1.0" encoding="utf-8" ?>
    <name>Neeraj Srivastava</name>
    <name>Sanjay kumar</name>
    <name>Arun Kumar</name>
    <name>Meenakshi Pandey</name>

Source Code:-

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
    <div align="center">
        <fieldset style="width: 250px;">
            <legend>XML Bind with Gridview</legend>
            <asp:GridView ID="gdemp" runat="server">


Code behind:-

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 bindxml : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    private void BindddlXml()
        using (DataSet ds = new DataSet())
            gdemp.DataSource = ds;

 Out Put:-

How to bind xml with grid view in c# How to bind xml with grid view in c# Reviewed by NEERAJ SRIVASTAVA on 8:59:00 PM Rating: 5

No comments:

Powered by Blogger.