ASP.NET

Exploring DataList Control in ASP.NET

To begin with, in this post on Exploring DataList Control in ASP.NET, I will explain the DataList control. In short, it is one of the feature-rich, lightweight data-bound control available in ASP.NET. In general, we use the DataList control to display the multiple rows of data.

Although, ASP.NET offers several data-bound controls but the DataList control provides much greater degree of customization and appearance control. The following list shows the important features of the DataList control.

Important Points Regarding the DataList Control

  1. Basically, it is a template-based control.
  2. Therefore, it contains several different types of templates that we can utilize to display and manipulate data items.
  3. In order to control the appearance of displayed data, the DataList control has corresponding style properties for each template.
  4. Since it acts as the container of data, the dataList control may use either data from a DataTable object or data from a physical database.

Templates Used in the DataList Control

As can be seen below, the DataList control can have following seven types of templates.

  1. In general, the ItemTemplate is responsible for displaying the content of the data source in the list. Also, it is the mandatory template that you should always include in the DataList control.
  2. Another template that displays the data items is known as the AlternatingItemTemplate. Basically, it displays the alternate rows of data when you include this template in the DataList control. Otherwise, the alternate rows of data items also displayed using the ItemTemplate only.
  3. Since you want to use different types of controls when an item is being edited, you can do this using the EditItemTemplate. Basically, this template provides the controls for editing the current item.
  4. Whenever you want to display the currently selected item in a particular way, you can use the SelectedItemTemplate that specifies the content and layout of the current selection.
  5. In order to display the header section in a specific format, you can use the HeaderTemplate.
  6. Likewise, you can also display the footer section using the FooterTemplate.
  7. Finally, a SeparatorTemplate specifies a separator between the items of the DataList.

The following figure shows an example of displaying data using the DataList control.

Exploring DataList Control in ASP.NET
Exploring DataList Control in ASP.NET

Summary

In this article on Exploring DataList Control in ASP.NET, you have learned the basic concepts of the DataListControl. Also, the different types of templates available with control are also discussed here. In the next article, you will learn the properties, methods, and events contained in the DataList.


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

Leave a Reply

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