Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline
Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Trial Issue of Visual Studio Magazine

email article
printer friendly
get the code
more resources

Bind XML Data in ASP.NET
Display dynamic Web content by using XML files as the data source and databinding to ASP.NET list controls.
by Stan Schultes

April 2003 Issue

Technology Toolbox: VB.NET, ASP.NET, XML, ASP

The ubiquitous XML is quickly becoming the Web's data language. The .NET Framework offers many ways to access and manipulate data, including XML. Reading your Web pages' source data from XML files has several advantages over loading content from a database. You can construct XML files easily and generate them from a database or other source. You can split your data into small, easily transportable pieces. Also, you can use XML without any licensing fees or restrictions. I'll take you through a sample application to show how you can drive dynamic content on your Web pages by using XML as the data source bound to the ASP.NET DataList control.

Figure 1. Drive Page Content From XML Files.

The sample app uses a partial index of my Getting Started columns as the data. The articles.aspx page displays the list of articles in a DataList control. Each entry consists of four lines. The first line displays both the article title as a hyperlink to the online article, and the Technology Toolbox. The second line contains the magazine, column type, and publication date. The third line is a short description of the article, and the final line contains a hyperlink for downloading the code (see Figure 1). The hyperlinks post back to the page with a QueryString parameter, giving you the opportunity to log page and file-download requests.

The data representing this structure lives in an XML file on the Web server in this format (abbreviated from the demoflat.xml sample file):

<articles>
   <article> 
      <title>Create...</title>
      <type>Getting Started</type>
      <readurl>gs0301a</readurl>
   </article>
</articles>

The <article> element repeats for each article the file lists.


Back to top














Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home