Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
SQL Server

How to bind XML file with Repeater Control

Author: DevASP Team

In this article I will try to explain you the tip of binding xml file with repeater control. The technique is very simple and easy to understand.

To begin with this, create a new web application in 2.0 and add a repeater control. In repeater control define three different templates. The first one would be your header template, second one will be the item template and last one will be separator template. The reason for adding these templates is user feel easy to read data o your site easily. The aspx code for your page is look like as follows:


<asp:Repeater ID="Repeater1" runat="server">

   <HeaderTemplate >TitleheaderTemplate>

   <ItemTemplate ><%# Eval("title") %>ItemTemplate>       

   <SeparatorTemplate ><hr />SeparatorTemplate>



Now the only thing you need to do is bind the xml file with the repeater control on the page load or on the event which you want to. For example you can bind on the button click event it depends on your requirement. The first step you will do is create a new reference of dataset and call the ReadXml method with parameter as (path of ) xml file this file will be in your project folder. The code for this is as follows:


ds = New DataSet


Repeater1.DataSource = ds


Add Article Comment:
Name :
Email Address :
Comments :
<< Calendar Control Date Methods

Disclaimer - Privacy
© 2002-2018