ASP.NET - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

ASP.NET DataList

ASP.NET DataList

shape Description

The ASP.NET DataList is used to show multiple records in a repeated manner. It has one special property, that the DataList control adds a table around the data items. by default, one can use “test.xml” as data source for the DataList control. [html]<?xml version="1.0" encoding="utf-8" ?> <technologies> <technology> <text>ASP.NET</text> <value>A</value> </technology> <technology> <text>JAVA</text> <value>J</value> </technology> <technology> <text>HTML</text> <value>H</value> </technology> </technologies>[/html] By using one DataSet, for which the data source is “test.xml” and at page load this DataSet will be loaded with the values. One have to use “System.Data” namespace here.

shape DataList

One can bind the data for a DataList like shown below. [csharp]protected void Page_Load(object sender, EventArgs e) { DataSet spDataSet = new DataSet(); spDataSet.ReadXml(MapPath("test.xml")); spRepeater.DataSource = spDataSet; spRepeater.DataBind(); }[/csharp] At the page load we will get the screen with the items entered in the xml file. Basic structure of a DataList is mentioned below. [html] <asp:DataList id="spDataList" runat="server"> <HeaderTemplate> .... </HeaderTemplate> <ItemTemplate> .... </ItemTemplate> <FooterTemplate> .... </FooterTemplate> </asp:DataList> [/html] This has to be write in between form tags.