ARTICLE

How to display an XmlNode contents in a DataGrid?

Posted by Mahesh Chand Articles | VB.NET FAQ August 30, 2006
Tags: DataGrid, XmlNode
This code snippet shows how you can show an XmlNode contents in a DataGrid.
 
Reader Level:

There are several occasions specially when accessing Web Services; data coming from the Web Service is in an XmlNode, not in DataSet and you want to display the contents of the XmlNode in a DataGrid.

 

The way to do is, simply convert XmlNode into a DataSet object and bind the DataSet to the DataGrid.

 

Dim funcAreasNode As XmlNode = GetNode()

If Not node Is Nothing And node.InnerXml.Length > 0 Then

Dim reader as XmlTextReader = New XmlTextReader(node.OuterXml, XmlNodeType.Element, Nothing)

Dim ds as DataSet = New DataSet

ds.ReadXml(reader)

End If

DataGrid1.DataSource = ds

DataGrid1.DataBind()

share this article :
post comment
 

I did not understand this bit DataGrid1.DataBind() Can u explain a bit more. Thanks.

Posted by Abdul Rahim Khan Mar 07, 2007
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Nevron Diagram
Become a Sponsor