Properties and Methods of DataList Control in ASP.NET

As I have said in my previous post on DataList control, it is a template-based data-bound control. For the purpose of understanding the basics of DataList Control, read this article. Today I will explain Properties and Methods of DataList Control in ASP.NET.

Properties and Methods of DataList Control

Since the DataList control is a container control for data items, it contains properties for the layout of data items, their appearance, how to display different sections of the list, key fields for data manipulation, and so on. Accordingly, some of the important properties of the DataList control are given below.

Contents and Layout

As discussed earlier, the DataList control makes use of templates for displaying data items in different sections of the list. Accordingly, it has ItemTemplate and AlternatingItemTemplate for displaying the data items. Similarly, the HeaderTemplate and the FooterTemplate show the header and footer sections respectively. Furthermore, EditItemTemplate and SelectedItemTemplate show the item currently being edited or selected respectively. Finally, the SeparatorTemplate shows the separator between data items.

Customization of Appearance

For the purpose of customization of appearance, the DataList control offers the Style property associated with each type of template. Accordingly, it has ItemStyle, AlternatingItemStyle, HeaderStyle, FooterStyle, EditItemStyle, SelectedItemStyle, and SeparatorStyle properties.

Direction of Display of DataList Items

The following properties control direction of the display, and the number of columns in the DataList control.

  • RepeatColumn
  • RepeatDirection
  • RepeatLayout

Therefore, the number of columns in the DataList is determined by the RepeatColumn property. Whereas, whether the data items are displayed row-wise or column-wise, is determined by the RepeatDirection property. Accordingly, the Horizontal value for RepeatDirection indicates the display of data items row-wise, whereas the Vertical value for RepeatDirection indicates the display of data items column-wise. Moreover, the RepeatLayout property specifies whether the layout is Table or Flow.

Display Header and Footer Sections

Since the header and footer sections of the DataList control are not visible by default, it has two properties for it – ShowHeader, and ShowFooter. As can be seen, both of these properties are boolean and make the header and footer section visible respectively when set to true.

Data Keys

Since, the DataList control allows edit, and delete functions of data items, it also has properties for managing data keys. For instance, for specifying the data key, we can use the DataKeyField property. Also, the DataKeys refers to the collection of keys for each record. Moreover, if you want to retrieve the keys as an object of ArrayList, you can use the DataKeysArray property. Furthermore, the DataList also has a property known as EditItemIndex that returns the index of the item currently being edited.

Apart from properties, the DataList control also has several fields, methods, and events. Read more on DataList members here.


In this article on Properties and Methods of DataList Control in ASP.NET, the important properties of this control are discussed. While, the fields, methods, and events will be discussed in the next article.

Related Topics

A Brief Overview of Laravel

Examples of AdRotator Control in ASP.NET

Overview of MVC architecture in ASP.NET

Binding Data to Web Control in ADO.NET

Examples of Validation Controls in ASP.NET

Data Binding Using BulletedList Control

Validation Summary Control in ASP.NET

An Example of Data Binding with RadioButtonList Control

Validation Controls Examples – RequiredFieldValidator, CompareValidator, and RangeValidator

Custom Validator Control in ASP.NET

Exploring DataList Control in ASP.NET

ASP.NET Practice Exercise

Leave a Reply

Your email address will not be published. Required fields are marked *