CodeSnip: Fill A DataGrid From An XML File
page 1 of 1
Published: 27 Aug 2004
Unedited - Community Contributed
Abstract
The code below demonstrates how to populate an ASP.NET DataGrid control with the contents of an XML file.
by Web Team at ORCS Web
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 10524/ 11

The code below demonstrates how to populate an ASP.NET DataGrid control with the contents of an XML file.

<%Page Language="VB" Trace="false"%> 
<%@Import Namespace="System.Data"%> 
<script language="VB" runat="server"> 
Sub Page_Load(Src as Object, E as EventArgs) 
  Dim oDataSet As DataSet = New DataSet oDataSet.ReadXml
  ("C:\GridTest\authors.xml",XmlReadMode.ReadSchema) 
  oGrid.DataSource=oDataSet 
  oGrid.DataBind() 
End Sub 
</script> 
<html> 
  <head> 
    <title>Fill A DataGrid From An XML File</title> 
  </head> 
  <body> 
    <asp:DataGrid id="oGrid" runat="server" /> 
  </body> 
</html>

by Brad Kingsley is Founder and President of ORCS Web, Inc. - a company that provides managed hosting services for clients who develop and deploy their applications on Microsoft Windows platforms.



User Comments

Title: Re xml Query   
Name: nonametouse
Date: 2008-04-21 5:28:16 AM
Comment:
I can't do it.I'm using C#
Title: RE:xml Query   
Name: michelle
Date: 2005-04-28 1:07:14 AM
Comment:
i think u can use Xquery for this.
Title: RE: XML query   
Name: Flügger
Date: 2005-01-26 11:57:28 AM
Comment:
I don't know any VB or ASP, but in c# you would just add
oGrid.DataMember = "whatever";
in order to specity which list(s) are displayed.

Hope it works for you.
Title: XML query   
Name: Colin
Date: 2005-01-10 1:36:10 PM
Comment:
this is great, but is there anyway to query the xml file to customize what is displayed in the datagrid?

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-20 8:57:03 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search