Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i want to retrieve the datas from xml and display it in gridview, what is the solution for this.From this XML file.....


XML
<?xml version="1.0" encoding="utf-8"?>
<EmpolyeeDetails>
  <Employee EmpId="001">
    <Name>Admin</Name>
    <Designation>SalesMan</Designation>
    <Phone>343434</Phone>
    <Address>xxxxxxx</Address>
    <Password>temp@123</Password>
  </Employee>
  <Employee EmpId="002">
    <Name>Kamal</Name>
    <Designation>6546565</Designation>
    <Phone>SalesMan</Phone>
    <Address>testing</Address>
    <Password>temp@123</Password>
  </Employee>
</EmpolyeeDetails>
Posted
Updated 22-Dec-11 5:13am
v3
Comments
RaviRanjanKr 23-Dec-11 16:03pm    
similar to http://www.codeproject.com/Questions/304783/retrieve-the-datas-from-xml

check these links..

bind xml to grid[^]

xml to grid[^]

xml file to gridview[^]

hope this helps..
 
Share this answer
 
Try to do once yourself. With help of tutorials....
If u find any difficulty then write here about your problem.
View the link below:
http://www.daniweb.com/web-development/aspnet/threads/91102[^]
 
Share this answer
 
Big deal?
C#
DataSet ds = new DataSet();
ds.ReadXml("Filename.xml");
Gridview1.DataSource = ds;
Gridview1.DataBind();
 
Share this answer
 
 
Share this answer
 
your question is very similar to this question-[retrieve the datas from xml][^].
 
Share this answer
 
XML
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Configuration"%>
<%@ Import Namespace="System.Data"%>

<script runat="server">
    void Page_Load(Object sender, EventArgs e)
    {
        DataSet authorsDataSet;
        string filePath = Server.MapPath("Authors.xml");
        authorsDataSet = new DataSet();
        //Read the contents of the XML file into the DataSet
        authorsDataSet.ReadXml(filePath);
        authorsGird.DataSource = authorsDataSet.Tables[0].DefaultView;
        authorsGird.DataBind();
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Reading XML Data into a DataSet object </title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView id="authorsGird" runat="server"
            AutoGenerateColumns="False" CellPadding="4" HeaderStyle-BackColor="blue" HeaderStyle-ForeColor="White"
            HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="True">
            <Columns>
                <asp:BoundField HeaderText="Last Name" DataField="lastName" />
                <asp:BoundField HeaderText="First Name"
                    DataField="firstName" ItemStyle-HorizontalAlign="Right" />
            </Columns>
        </asp:GridView>
    </div>
    </form>
</body>
</html>
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900