Login | Register  

Displaying XML to DataGrid

by Scud   Tuesday, September 26, 2006 Rating:
 Vote this news:


In this source code we will look at how to read an XML data source and how to put it on our ASP.NET page. For this example you can use a sample XML file putting same folder with our source code.

Here is the comple code :

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
    Dim ds as new DataSet

    DS.ReadXml(Server.MapPath("gazatem-com-sitemap.xml"))
    dg.DataSource = DS
    dg.DataBind()
end sub    
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>

<asp:DataGrid runat="server" Id="dg" cellpadding="0" cellspacing="2" width="96%" font-size = "10pt" RepeatColumns="1"
/>
</body>
</html>
   

We have drawed some parts of code with yellow color to understand the major parts of this simple code. First you should import necassary namespaces to our code. Later we need to create a new dataset and with help of ReadXml .

Happy Coding




Dotnetindex.com is listed with 411asp.net
Dotnetindex.com is listed with aspin.com
Dotnetindex.com is listed with jspin.com
PHP, ASP, .NET, JSP Resources, Reviews







page counter
Copyright © 2007 Powered by GNews Publisher Positive. All rights reserved. Contact Us - Load Time: 0.03 second(s)