System.Web.UI.WebControls.BaseDataList Class

Serves as the abstract base class for data listing controls, such as System.Web.UI.WebControls.DataList and System.Web.UI.WebControls.DataGrid. This class provides the methods and properties common to all data listing controls.

See Also: BaseDataList Members

Syntax

[System.ComponentModel.Designer("System.Web.UI.Design.WebControls.BaseDataListDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
[System.ComponentModel.DefaultProperty("DataSource")]
[System.ComponentModel.DefaultEvent("SelectedIndexChanged")]
public abstract class BaseDataList : WebControl

Remarks

The System.Web.UI.WebControls.BaseDataList class provides the common functionality for all data listing controls, such as System.Web.UI.WebControls.DataList and System.Web.UI.WebControls.DataGrid. A data listing control is used to display the records from a data source, such as a System.Data.DataView control. Each data listing control can have a unique display style and capabilities. Because the System.Web.UI.WebControls.BaseDataList class is abstract, an instance of this class is not created directly. Instead, data listing controls inherit the methods and properties common to all data listing controls from this class.

You can control the appearance of a data listing control by setting certain properties of this class. To determine the amount of spacing between the cells of a data listing control, set the BaseDataList.CellSpacing property. To determine the amount of spacing between the contents of a cell and the cell's border, set the BaseDataList.CellPadding property. You can display the border between the individual cells of a data listing control by setting the BaseDataList.GridLines property. The horizontal alignment of the content in the cells of a data listing control is controlled by the BaseDataList.HorizontalAlign property.

The System.Web.UI.WebControls.BaseDataList class provides two properties to support data binding. To bind data to any collection that implements the IEnumerable interface (such as System.Data.DataView or ArrayList), or the System.ComponentModel.IListSource interface, use the BaseDataList.DataSource property to specify the data source. When you set the BaseDataList.DataSource property, you must manually write the code to perform the data binding. To automatically bind a data listing control to a data source represented by a data source control, use the BaseDataList.DataSourceID property and set its value to the System.Web.UI.Control.ID property of the data source control to use. When you set the BaseDataList.DataSourceID property, the data listing control automatically binds to the specified data source control. Therefore, you do not need to explicitly call the BaseDataList.DataBind method.

If the data source specified by the BaseDataList.DataSource property contains multiple sources of data, use the BaseDataList.DataMember property to specify the specific source to bind to the control. For example, if you have a System.Data.DataSet object with multiple tables, you must specify which table to bind to the control. After you have specified the data source, use the BaseDataList.DataBind method to bind the data source to the control.

The System.Web.UI.WebControls.BaseDataList class contains a BaseDataList.DataKeys collection that stores the key field of each record (displayed as a row) in a data listing control. This allows you to store the key field with a data listing control without displaying it in the control. The key field is commonly used as part of an update query string to revise a specific record in the data source. The collection is filled with the values from the field specified by the BaseDataList.DataKeyField property.

The System.Web.UI.WebControls.BaseDataList class provides a BaseDataList.SelectedIndexChanged event that is raised when the selected item in the control changes. This allows you to create a custom event handler that performs a specific set of instructions when the event is raised.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0