Datagrid Bind Xml File

Here How to Bind Datagrid from asp.net using xml file.

First Step
Dotnet Project->open-->Website-->Add New ITem-> Xml File

change the code like this


<?xml version="1.0" encoding="utf-8" ?>
<menu>
<File>
Open
</File>
</menu>



then open ur project file .aspx file

Write the code like this
server side


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dt As New Data.DataSet
dt.ReadXml(Server.MapPath("XMLFile.xml"))
mnu1.DataSource = dt
mnu1.DataBind()
End Sub


Client Side code


< html xmlns="http://www.w3.org/1999/xhtml" >
< head runat="server" >
< title >Untitled Page < /title >
< /head >
< body >
< form id="form1" runat="server" >

< asp:DataGrid ID="mnu1" runat ="server" AutoGenerateColumns ="false" >
< Columns >
< asp:TemplateColumn HeaderText ="FileMenu" >
< ItemTemplate >
< asp:Label ID="lbl1" runat ="Server" Text =' < %#Databinder.eval(Container,"Dataitem.File") % >' > < /asp:Label >
< /ItemTemplate >
< /asp:TemplateColumn >
< /Columns >
< /asp:DataGrid >
< /form >
< /body >
< /html >


thanks
kumar


Comments

Author: Mrs. Meetu Choudhary Nanda04 Jul 2009 Member Level: Gold   Points : 2

Please Format Your Resource Properly to get approved.

++
Thanks and Regards
Meetu Choudhary
Site coordinator.

Author: Jayakumar.R04 Jul 2009 Member Level: Gold   Points : 1

here my xml code doesnot show
my code in Code tag


xml tag here


i am post msg webmaster

thanks
kumar

Author: Mrs. Meetu Choudhary Nanda04 Jul 2009 Member Level: Gold   Points : 2

Format it as you did the HTML Code. use &.l.t.; and &.g.t.; without points.

++
Thanks and Regards
Meetu Choudhary
Site Coordinator.

Author: Jayakumar.R04 Jul 2009 Member Level: Gold   Points : 0

now change and post here pl check and approved.



Author: Mrs. Meetu Choudhary Nanda04 Jul 2009 Member Level: Gold   Points : 1

Still It was not corrected I have modified the code .

++
Thanks and Regards
Meetu Choudhary
Site Coordinator.

Author: Jayakumar.R04 Jul 2009 Member Level: Gold   Points : 0

Dear Mam

here how to format xml tag i am format as a like html method



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: