Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

BaseDataList Class

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

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public abstract class BaseDataList : WebControl
public abstract class BaseDataList extends WebControl
public abstract class BaseDataList extends WebControl

The BaseDataList class provides the common functionality for all data listing controls, such as DataList and 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 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 CellSpacing property. To determine the amount of spacing between the contents of a cell and the cell's border, set the CellPadding property. You can display the border between the individual cells of a data listing control by setting the GridLines property. The horizontal alignment of the content in the cells of a data listing control is controlled by the HorizontalAlign property.

The BaseDataList class provides two properties to support data binding. To bind data to any object that implements the System.Collections.IEnumerable interface (such as System.Data.DataView, System.Collections.ArrayList, and System.Collections.Hashtable), or the IListSource interface, use the DataSource property to specify the data source. When you set the 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 DataSourceID property and set its value to the ID property of the data source control to use. When you set the DataSourceID property, the data listing control automatically binds to the specified data source control. Therefore, you do not need to explicitly call the DataBind method.

If the data source specified by the DataSource property contains multiple sources of data, use the 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 DataBind method to bind the data source to the control.

The BaseDataList class contains a 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 DataKeyField property.

The BaseDataList class provides a 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.

Notes to Inheritors When you inherit from BaseDataList, you must override the following members: CreateControlHierarchy and PrepareControlHierarchy.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.