Serves as the abstract base class that defines the properties, methods, and events common for all list-type controls.
See Also: ListControl Members
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.