System.Web.UI.WebControls.ListControl Class

Serves as the abstract base class that defines the properties, methods, and events common for all list-type controls.

See Also: ListControl Members

Syntax

[System.Web.UI.ControlValueProperty("SelectedValue", null)]
[System.Web.UI.ParseChildren(true, "Items")]
[System.ComponentModel.Designer("System.Web.UI.Design.WebControls.ListControlDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
[System.ComponentModel.DefaultEvent("SelectedIndexChanged")]
[System.Web.UI.DataBindingHandler("System.Web.UI.Design.WebControls.ListControlDataBindingHandler, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public abstract class ListControl : DataBoundControl, System.Web.UI.IEditableTextControl

Remarks

An instance of the System.Web.UI.WebControls.ListControl abstract class cannot be created directly. Instead, this class is inherited by other classes, such as the System.Web.UI.WebControls.CheckBoxList, System.Web.UI.WebControls.DropDownList, System.Web.UI.WebControls.ListBox, and System.Web.UI.WebControls.RadioButtonList classes, to provide common basic functionality.

The properties of the System.Web.UI.WebControls.ListControl class allow you to specify the source of the data to populate the list control. Use the BaseDataBoundControl.DataSource property to specify the data source to bind to the list control. If the data source contains more than one table, use the DataBoundControl.DataMember property to specify the table to use. You can bind different fields in the data source to the ListItem.Text and ListItem.Value properties of the items in the list control by setting the ListControl.DataTextField and ListControl.DataValueField properties, respectively. The text displayed for each item in the list control can by formatted by setting the ListControl.DataTextFormatString property.

All items displayed in the list control are stored in the ListControl.Items collection. You can programmatically specify or determine the index of a selected item in the list control by using the ListControl.SelectedIndex property. The properties of the selected item can be accessed by using the ListControl.SelectedItem property.

The System.Web.UI.WebControls.ListControl class provides the ListControl.SelectedIndexChanged event, which is raised when the selection in the list control changes between posts to the server. This allows you to provide a custom handler for this event. For more information about handling events, see Consuming Events.

The System.Web.UI.WebControls.ListControl class implements the System.Web.UI.IEditableTextControl interface so that derived list-type controls can be used in the template mode of other controls.

Requirements

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