System.Web.UI.WebControls (system.web.dll)class

The DataList control is a data-bound list that is configured through templates in the .aspx file. It does not provide quite the extent of features found in the DataGrid control. It does provide support for automatic selection (by setting the SelectedIndex property) and editing (by setting the EditItemIndex property), but not for automatic paging or sorting. Also, there is no support for default column types or automatically generated rows, so you will always need to specify at least an ItemTemplate. Templates for the DataList are bracketed inside the appropriate template tag (like <ItemTemplate>) and may contain a data-binding expression (for example, <%# Container.DataItem("Description") %>). You can also add HTML tags or tags for ASP.NET controls to these templates manually for a customized appearance.

You can use the AlternatingItemTemplate property to allow items to alternate between two styles, the EditItemTemplate to specify how items will appear when they are being edited, and the SelectedItemTemplate to specify how items will appear when they are selected. The HeaderTemplate, FooterTemplate, and SeparatorTemplate allow you specify layout and content for special rows. The DataList has a number of properties that allow you to control its appearance. You can set TableItemStyle objects for various properties, including footers, headers (used automatically for column titles), and items. (The corresponding DataList properties end with the word "Style.") You can also use the ShowHeader and ShowFooter properties to configure whether headers and footers will be displayed.

public class DataList : BaseDataList, System.Web.UI.INamingContainer, IRepeatInfoUser {
// Public Constructors
   public DataList( );
// Public Static Fields
   public const string CancelCommandName;           // =Cancel
   public const string DeleteCommandName;           // =Delete
   public const string EditCommandName;             // =Edit
   public const string SelectCommandName;           // =Select
   public const string UpdateCommandName;           // =Update
// Public Instance Properties
   public virtual TableItemStyle AlternatingItemStyle{get; }
   public virtual ITemplate AlternatingItemTemplate{set; get; }
   public virtual int EditItemIndex{set; get; }
   public virtual TableItemStyle EditItemStyle{get; }
   public virtual ITemplate EditItemTemplate{set; get; }
   public virtual bool ExtractTemplateRows{set; get; }
   public virtual TableItemStyle FooterStyle{get; }
   public virtual ITemplate FooterTemplate{set; get; }
   public override GridLines GridLines{set; get; }               // overrides BaseDataList
   public virtual TableItemStyle HeaderStyle{get; }
   public virtual ITemplate HeaderTemplate{set; get; }
   public virtual DataListItemCollection Items{get; }
   public virtual TableItemStyle ItemStyle{get; }
   public virtual ITemplate ItemTemplate{set; get; }
   public virtual int RepeatColumns{set; get; }
   public virtual RepeatDirection RepeatDirection{set; get; }
   public virtual RepeatLayout RepeatLayout{set; get; }
   public virtual int SelectedIndex{set; get; }
   public virtual DataListItem SelectedItem{get; }
   public virtual TableItemStyle SelectedItemStyle{get; }
   public virtual ITemplate SelectedItemTemplate{set; get; }
   public virtual TableItemStyle SeparatorStyle{get; }
   public virtual ITemplate SeparatorTemplate{set; get; }
   public virtual bool ShowFooter{set; get; }
   public virtual bool ShowHeader{set; get; }
// Protected Instance Methods
   protected override void CreateControlHierarchy(bool useDataSource);  // overrides BaseDataList
   protected override Style CreateControlStyle( );                // overrides WebControl
   protected virtual DataListItem CreateItem(int itemIndex, ListItemType itemType);
   protected virtual void InitializeItem(DataListItem item);
   protected override void LoadViewState(object savedState);    // overrides WebControl
   protected override bool OnBubbleEvent(object source, EventArgs e);// overrides System.Web.UI.Control
   protected virtual void OnCancelCommand(DataListCommandEventArgs e);
   protected virtual void OnDeleteCommand(DataListCommandEventArgs e);
   protected virtual void OnEditCommand(DataListCommandEventArgs e);
   protected virtual void OnItemCommand(  DataListCommandEventArgs e);
   protected virtual void OnItemCreated(DataListItemEventArgs e);
   protected virtual void OnItemDataBound(DataListItemEventArgs e);
   protected virtual void OnUpdateCommand(DataListCommandEventArgs e);
   protected override void PrepareControlHierarchy( );            // overrides BaseDataList
   protected override void RenderContents(System.Web.UI.HtmlTextWriter writer);  // overrides WebControl
   protected override object SaveViewState( );                    // overrides WebControl
   protected override void TrackViewState( );                     // overrides WebControl
// Events
   public event DataListCommandEventHandler CancelCommand;
   public event DataListCommandEventHandler DeleteCommand;
   public event DataListCommandEventHandler EditCommand;
   public event DataListCommandEventHandler ItemCommand;
   public event DataListItemEventHandler ItemCreated;
   public event DataListItemEventHandler ItemDataBound;
   public event DataListCommandEventHandler UpdateCommand;


System.Object System.Web.UI.Control(System.ComponentModel.IComponent, System.IDisposable, System.Web.UI.IParserAccessor, System.Web.UI.IDataBindingsAccessor) WebControl(System.Web.UI.IAttributeAccessor) BaseDataList DataList(System.Web.UI.INamingContainer, IRepeatInfoUser)

    Part I: Introduction to ASP.NET
    Part III: Namespace Reference
    Chapter 40. The System.Web.UI.MobileControls Namespace
    Chapter 42. The System.Web.UI.WebControls Namespace