C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Visual Studio »

Datagrid Bind Xml File


Posted Date: 04 Jul 2009    Resource Type: Code Snippets    Category: Visual Studio
Author: R.Jaya kumar (JK)Member Level: Diamond    
Rating: 1 out of 5Points: 8 (Rs 5)



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



Responses

Author: Miss Meetu Choudhary    04 Jul 2009Member Level: Diamond   Points : 2
Please Format Your Resource Properly to get approved.

++
Thanks and Regards
Meetu Choudhary
Site coordinator.


Author: R.Jaya kumar (JK)    04 Jul 2009Member Level: Diamond   Points : 1
here my xml code doesnot show
my code in Code tag


xml tag here


i am post msg webmaster

thanks
kumar



Author: Miss Meetu Choudhary    04 Jul 2009Member Level: Diamond   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: R.Jaya kumar (JK)    04 Jul 2009Member Level: Diamond   Points : 0
now change and post here pl check and approved.






Author: Miss Meetu Choudhary    04 Jul 2009Member Level: Diamond   Points : 1
Still It was not corrected I have modified the code .

++
Thanks and Regards
Meetu Choudhary
Site Coordinator.



Author: R.Jaya kumar (JK)    04 Jul 2009Member Level: Diamond   Points : 0
Dear Mam

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


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Datagrid Bind Xml File  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Save Data's from Database table to a DES Encrypted file in VB.net
Previous Resource: Records navigate first,next,previous,last
Return to Discussion Resource Index
Post New Resource
Category: Visual Studio


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use