IT Community - Software Programming, Web Development and Technical Support

How to bind the xml data directly in to datgrid with out using dataset?

This is a discussion on How to bind the xml data directly in to datgrid with out using dataset? within the ASP and ASP.NET Programming forums, part of the Web Development category; How to bind the xml data directly in to datgrid with out using dataset?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  3 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 07-19-2007, 11:16 PM
bluesky bluesky is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 201
bluesky is on a distinguished road
Default How to bind the xml data directly in to datgrid with out using dataset?

How to bind the xml data directly in to datgrid with out using dataset?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-20-2007, 12:35 AM
Gopisoft Gopisoft is offline
D-Web Sr.Programmer
 
Join Date: Feb 2007
Posts: 117
Gopisoft is on a distinguished road
Default Re: How to bind the xml data directly in to datgrid with out using dataset?

Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If Not IsPostBack Then
        Dim oXML As New XmlDataDocument
        oXML.Load(Server.MapPath("Client.xml"))
        DataGrid1.DataSource = oXML.SelectNodes("Client/Personal")
        DataGrid1.DataBind()
    End If
End Sub


<?xml version="1.0" encoding="utf-8" ?> 

<Client>

<Personal>
	<ClientID>1</ClientID>
	<ClientName>Sample</ClientName>
</Personal>

<Personal>
	<ClientID>2</ClientID>
	<ClientName>Test</ClientName>
</Personal>

<Personal>
	<ClientID>3</ClientID>
	<ClientName>Example</ClientName>
</Personal>

<Personal>
	<ClientID>4</ClientID>
	<ClientName>Model</ClientName>
</Personal>


</Client>
Note : You can set any object which implements IEnumerable as datasource to DataGrid. Since XMLDocument doesnt implement IEnumberable to DataGrid, we use Nodes collection of XMLDocument which implement IEnumberable as DataSource To Datagrid


--R.Gopi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-20-2007, 12:54 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: How to bind the xml data directly in to datgrid with out using dataset?

aspx page

<asp:datagrid id="DataGrid1" runat="server" BorderColor="black" HeaderStyle-BackColor="#aaaadd" HeaderStyle-CssClass="tableHeader" ItemStyle-CssClass="tableItem"
AllowPaging="False" width="700px" AutoGenerateColumns=False>
<Columns>
<asp:TemplateColumn headertext="Product ID" >
<ItemTemplate >
<asp:TextBox style= "width:100px;" id="ProductID" runat= "server" Text='<%# CType(Container.DataItem,System.XML.XMLNode)("Prod uctID").InnerText%>' >
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>

</asp:datagrid>

Code Behind
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim oXML As New XmlDataDocument
oXML.Load(Server.MapPath("product.xml"))
DataGrid1.DataSource = oXML.SelectNodes("Product")
DataGrid1.DataBind()
End If
End Sub
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/asp-asp-net-programming/2265-how-bind-xml-data-directly-datgrid-out-using-dataset.html
Posted By For Type Date
Digg / Technology / Upcoming This thread Refback 07-20-2007 04:59 AM
Digg / Technology / Upcoming This thread Refback 07-20-2007 02:03 AM
Digg / News / Upcoming This thread Refback 07-20-2007 02:02 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the difference between "using System.Data;" and directly adding the refer KiruthikaSambandam ASP and ASP.NET Programming 1 11-15-2007 01:33 AM
Can anybody explain about the differences between dataset.clone and dataset.copy? kingmaker C# Programming 2 08-28-2007 12:22 AM
What is the difference between "using System.Data;" and directly adding the reference H2o ASP and ASP.NET Programming 1 07-24-2007 03:33 AM
How to bind data in repeater when i use two repeater's in nested format? kingmaker ASP and ASP.NET Programming 1 07-20-2007 03:28 AM
I have a repeater in which I want to bind multiple images, if I... kingmaker ASP and ASP.NET Programming 0 07-16-2007 11:22 PM


All times are GMT -7. The time now is 07:01 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0