datalist control in asp .net

datalist control in

 DataList control in  has RepeatDirection, RepeatColumns and RepeatLayout properties, which are unique for DataList control. These properties are useful when you need to create presentation with more than one record per row, like Image Gallery, Product Catalogue etc. For example, let say you are creating an image gallery and want to show 5 images per row. Repeater would require checking of record position and manipulating HTML. With DataList, just use RepeatDirection=”Horizontal” and RepeatColumns=”5″. RepeatLayout could be Table or Flow, depending of do you need HTML table structure in layout. These features are not possible using any other data controls.

The DataList control like the Repeater control is a template driven, light weight control, and acts as a container of repeated data items. The templates in this control are used to define the data that it will contain. It is flexible in the sense that you can easily customize the display of one or more records that are displayed in the control.

The DataList Web server control displays data in a format that you can define using templates and styles. The DataList control is useful for data in any repeating structure, such as a table. The DataList control can display rows in different layouts, such as ordering them in columns or rows.

This comes in handy, especially in situations where you have too many columns in your database table or columns with larger widths of data. As an example, imagine what would happen if there is a field called Address in our Employee table having data of large size and you are displaying the data using a Repeater, a DataGrid, or a GridView control. You will not be able to display columns of such large data sizes with any of these controls as the display would look awkward. This is where the DataList control fits in.

When the web page is in execution with the data bound to it using the Page_Load event, the data in the DataList control is rendered as DataListItem objects, that is, each item displayed is actually a DataListItem. Similar to the Repeater control, the DataList control supports Editing and Deleting features whereas Repeater does not support. The DataList control does not have Paging and Sorting functionalities built into it similar to Repeater control.



CssClass: It enables us to associate a CSS class with the DataList.

HeaderStyle: It enables us to format the header row of the DataList.

FooterStyle: It enables us to format the footer row of the DataList.

ItemStyle: It enables us to format each row displayed by the DataList.

AlternatingItemStyle: It enables us to format every other row of the DataList.

EditItemStyle: It enables us to format the DataList row selected for editing.

SelectedItemStyle: It enables us to format the selected row in the DataList.

SeparatorStyle: It enables us to format the row separator displayed by the DataList.
When formatting the DataList, we also need to work with the following properties: 

GridLines: It enables us to add rules around the cells in the DataList. Possible values are None, Horizontal, Vertical, and Both.

ShowFooter: It enables us to show or hide the footer row.

ShowHeader: It enables us to show or hide the header row.

UseAccessibleHeader: It enables us to render HTML <th> tags instead of <td> tags for the cells in the header row.