• home
  • forum
  • my
  • kt
  • download
  • Displaying XML to DataGrid

    Author: 2007-07-05 10:05:46 From:

    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 .

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      NET (110)

    New

    Hot