Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
3605 lines (3115 sloc) 273 KB
<Type Name="DataList" FullName="System.Web.UI.WebControls.DataList">
<TypeSignature Language="C#" Value="public class DataList : System.Web.UI.WebControls.BaseDataList, System.Web.UI.INamingContainer, System.Web.UI.WebControls.IRepeatInfoUser" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit DataList extends System.Web.UI.WebControls.BaseDataList implements class System.Web.UI.INamingContainer, class System.Web.UI.WebControls.IRepeatInfoUser" />
<TypeSignature Language="DocId" Value="T:System.Web.UI.WebControls.DataList" />
<TypeSignature Language="VB.NET" Value="Public Class DataList&#xA;Inherits BaseDataList&#xA;Implements INamingContainer, IRepeatInfoUser" />
<TypeSignature Language="C++ CLI" Value="public ref class DataList : System::Web::UI::WebControls::BaseDataList, System::Web::UI::INamingContainer, System::Web::UI::WebControls::IRepeatInfoUser" />
<TypeSignature Language="F#" Value="type DataList = class&#xA; inherit BaseDataList&#xA; interface INamingContainer&#xA; interface IRepeatInfoUser" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Web.UI.WebControls.BaseDataList</BaseTypeName>
</Base>
<Interfaces>
<Interface>
<InterfaceName>System.Web.UI.INamingContainer</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Web.UI.WebControls.IRepeatInfoUser</InterfaceName>
</Interface>
</Interfaces>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8">
<AttributeName>System.ComponentModel.Designer("System.Web.UI.Design.WebControls.DataListDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8">
<AttributeName>System.ComponentModel.Editor("System.Web.UI.Design.WebControls.DataListComponentEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.ComponentModel.ComponentEditor))</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8">
<AttributeName>System.Web.UI.ControlValueProperty("SelectedValue")</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-1.1">
<AttributeName>System.ComponentModel.Designer("System.Web.UI.Design.WebControls.DataListDesigner, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-1.1">
<AttributeName>System.ComponentModel.Editor("System.Web.UI.Design.WebControls.DataListComponentEditor, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.ComponentModel.ComponentEditor))</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5">
<AttributeName>System.ComponentModel.Designer("System.Web.UI.Design.WebControls.DataListDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5">
<AttributeName>System.ComponentModel.Editor("System.Web.UI.Design.WebControls.DataListComponentEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.ComponentModel.ComponentEditor))</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>A data bound list control that displays items using templates.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
In this topic:
- [Introduction](#introduction)
- [Templates](#templates)
- [Customizing the Appearance of the DataList Control](#customizing_the_appearance_of_the_datalist_control)
- [Display Direction and Layout](#display_direction_and_layout)
- [Security](#security)
- [Declarative Syntax](#declarative_syntax)
<a name="introduction"></a>
## Introduction
Use the <xref:System.Web.UI.WebControls.DataList> control to display a template-defined data bound list. The <xref:System.Web.UI.WebControls.DataList> control supports selecting and editing.
<a name="templates"></a>
## Templates
The contents of the <xref:System.Web.UI.WebControls.DataList> control can be manipulated by using templates. The following table lists the supported templates.
|Template Name|Description|
|-------------------|-----------------|
|<xref:System.Web.UI.WebControls.DataList.AlternatingItemTemplate%2A>|If defined, provides the content and layout for alternating items in the <xref:System.Web.UI.WebControls.DataList>. If not defined, `ItemTemplate` is used.|
|<xref:System.Web.UI.WebControls.DataList.EditItemTemplate%2A>|If defined, provides the content and layout for the item currently being edited in the <xref:System.Web.UI.WebControls.DataList>. If not defined, `ItemTemplate` is used.|
|<xref:System.Web.UI.WebControls.DataList.FooterTemplate%2A>|If defined, provides the content and layout for the footer section of the <xref:System.Web.UI.WebControls.DataList>. If not defined, a footer section will not be displayed.|
|<xref:System.Web.UI.WebControls.DataList.HeaderTemplate%2A>|If defined, provides the content and layout for the header section of the <xref:System.Web.UI.WebControls.DataList>. If not defined, a header section will not be displayed.|
|<xref:System.Web.UI.WebControls.DataList.ItemTemplate%2A>|Required template that provides the content and layout for items in the <xref:System.Web.UI.WebControls.DataList>.|
|<xref:System.Web.UI.WebControls.DataList.SelectedItemTemplate%2A>|If defined, provides the content and layout for the currently selected item in the <xref:System.Web.UI.WebControls.DataList>. If not defined, <xref:System.Web.UI.WebControls.DataList.ItemTemplate%2A> is used.|
|<xref:System.Web.UI.WebControls.DataList.SeparatorTemplate%2A>|If defined, provides the content and layout for the separator between items in the <xref:System.Web.UI.WebControls.DataList>. If not defined, a separator will not be displayed.|
At the very minimum, the <xref:System.Web.UI.WebControls.DataList.ItemTemplate%2A> needs to be defined to display the items in the <xref:System.Web.UI.WebControls.DataList> control. Additional templates can be used to provide a custom look to the <xref:System.Web.UI.WebControls.DataList> control.
<a name="customizing_the_appearance_of_the_datalist_control"></a>
## Customizing the Appearance of the DataList Control
The appearance of the <xref:System.Web.UI.WebControls.DataList> control may be customized by setting the style properties for the different parts of the control. The following table lists the different style properties.
|Style Property|Description|
|--------------------|-----------------|
|<xref:System.Web.UI.WebControls.DataList.AlternatingItemStyle%2A>|Specifies the style for alternating items in the <xref:System.Web.UI.WebControls.DataList> control.|
|<xref:System.Web.UI.WebControls.DataList.EditItemStyle%2A>|Specifies the style for the item being edited in the <xref:System.Web.UI.WebControls.DataList> control.|
|<xref:System.Web.UI.WebControls.DataList.FooterStyle%2A>|Specifies the style for the footer in the <xref:System.Web.UI.WebControls.DataList> control.|
|<xref:System.Web.UI.WebControls.DataList.HeaderStyle%2A>|Specifies the style for the header in the <xref:System.Web.UI.WebControls.DataList> control.|
|<xref:System.Web.UI.WebControls.DataList.ItemStyle%2A>|Specifies the style for the items in the <xref:System.Web.UI.WebControls.DataList> control.|
|<xref:System.Web.UI.WebControls.DataList.SelectedItemStyle%2A>|Specifies the style for the selected item in the <xref:System.Web.UI.WebControls.DataList> control.|
|<xref:System.Web.UI.WebControls.DataList.SeparatorStyle%2A>|Specifies the style for the separator between the items in the <xref:System.Web.UI.WebControls.DataList> control.|
You can also show or hide different parts of the control. The following table lists the properties that control which parts are shown or hidden.
|Property|Description|
|--------------|-----------------|
|<xref:System.Web.UI.WebControls.DataList.ShowFooter%2A>|Shows or hides the footer section of the <xref:System.Web.UI.WebControls.DataList> control.|
|<xref:System.Web.UI.WebControls.DataList.ShowHeader%2A>|Shows or hides the header section of the <xref:System.Web.UI.WebControls.DataList> control.|
<a name="display_direction_and_layout"></a>
## Display Direction and Layout
The display direction of a <xref:System.Web.UI.WebControls.DataList> control can be vertical or horizontal. Set the <xref:System.Web.UI.WebControls.DataList.RepeatDirection%2A> property to specify the display direction.
The layout of the <xref:System.Web.UI.WebControls.DataList> control is controlled with the <xref:System.Web.UI.WebControls.DataList.RepeatLayout%2A> property. Setting this property to `RepeatLayout.Table` will display the <xref:System.Web.UI.WebControls.DataList> in a table format, while `RepeatLayout.Flow` displays the <xref:System.Web.UI.WebControls.DataList> without a table structure.
<a name="security"></a>
## Security
The `DataList` control can contain controls that enable users to enter information.
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input.
For more information about security, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
<a name="declarative_syntax"></a>
## Declarative Syntax
```
<asp:DataList
    AccessKey="string"
    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
Inset|Outset"
    BorderWidth="size"
    Caption="string"
    CaptionAlign="NotSet|Top|Bottom|Left|Right"
    CellPadding="integer"
    CellSpacing="integer"
    CssClass="string"
    DataKeyField="string"
    DataMember="string"
    DataSource="string"
    DataSourceID="string"
    EditItemIndex="integer"
    Enabled="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    ExtractTemplateRows="True|False"
    Font-Bold="True|False"
    Font-Italic="True|False"
    Font-Names="string"
    Font-Overline="True|False"
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
Large|X-Large|XX-Large"
    Font-Strikeout="True|False"
    Font-Underline="True|False"
    ForeColor="color name|#dddddd"
    GridLines="None|Horizontal|Vertical|Both"
    Height="size"
    HorizontalAlign="NotSet|Left|Center|Right|Justify"
    ID="string"
    OnCancelCommand="CancelCommand event handler"
    OnDataBinding="DataBinding event handler"
    OnDeleteCommand="DeleteCommand event handler"
    OnDisposed="Disposed event handler"
    OnEditCommand="EditCommand event handler"
    OnInit="Init event handler"
    OnItemCommand="ItemCommand event handler"
    OnItemCreated="ItemCreated event handler"
    OnItemDataBound="ItemDataBound event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnSelectedIndexChanged="SelectedIndexChanged event handler"
    OnUnload="Unload event handler"
    OnUpdateCommand="UpdateCommand event handler"
    RepeatColumns="integer"
    RepeatDirection="Horizontal|Vertical"
    RepeatLayout="Table|Flow"
    runat="server"
    SelectedIndex="integer"
    ShowFooter="True|False"
    ShowHeader="True|False"
    SkinID="string"
    Style="string"
    TabIndex="integer"
    ToolTip="string"
    UseAccessibleHeader="True|False"
    Visible="True|False"
    Width="size"
>
        <AlternatingItemStyle />
        <AlternatingItemTemplate>
<!-- child controls -->
        </AlternatingItemTemplate>
        <EditItemStyle />
        <EditItemTemplate>
<!-- child controls -->
        </EditItemTemplate>
        <FooterStyle />
        <FooterTemplate>
<!-- child controls -->
        </FooterTemplate>
        <HeaderStyle />
        <HeaderTemplate>
<!-- child controls -->
        </HeaderTemplate>
        <ItemStyle />
        <ItemTemplate>
<!-- child controls -->
        </ItemTemplate>
        <SelectedItemStyle />
        <SelectedItemTemplate>
<!-- child controls -->
        </SelectedItemTemplate>
        <SeparatorStyle />
        <SeparatorTemplate>
<!-- child controls -->
        </SeparatorTemplate>
</asp:DataList>
```
## Examples
The following code example demonstrates how to use a <xref:System.Web.UI.WebControls.DataList> control to display a list of items from a data source.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataList#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataList/CS/datalistcs.aspx#1)]
[!code-aspx-vb[DataList#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataList/VB/datalistvb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.BaseDataList" />
<altmember cref="T:System.Web.UI.WebControls.DataGrid" />
<altmember cref="T:System.Web.UI.WebControls.Repeater" />
<related type="Article" href="https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8">Securing Standard Controls</related>
<related type="Article" href="https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b">How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings</related>
<related type="Article" href="https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461">Validating User Input in ASP.NET Web Pages</related>
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public DataList ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; DataList();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.DataList" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use this constructor to create and initialize a new instance of the <xref:System.Web.UI.WebControls.DataList> class.
## Examples
The following code example demonstrates how to create and initialize a new instance of the <xref:System.Web.UI.WebControls.DataList> class.
[!code-csharp[Classic DataList.DataList Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic DataList.DataList Example/CS/source.cs#1)]
[!code-vb[Classic DataList.DataList Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic DataList.DataList Example/VB/source.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="AlternatingItemStyle">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.WebControls.TableItemStyle AlternatingItemStyle { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.TableItemStyle AlternatingItemStyle" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.AlternatingItemStyle" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property AlternatingItemStyle As TableItemStyle" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::WebControls::TableItemStyle ^ AlternatingItemStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };" />
<MemberSignature Language="F#" Value="member this.AlternatingItemStyle : System.Web.UI.WebControls.TableItemStyle" Usage="System.Web.UI.WebControls.DataList.AlternatingItemStyle" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(null)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.NotifyParentProperty(true)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.TableItemStyle</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the style properties for alternating items in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<value>A <see cref="T:System.Web.UI.WebControls.TableItemStyle" /> object that represents the style properties for alternating items in the <see cref="T:System.Web.UI.WebControls.DataList" /> control. The default value is an empty <see cref="T:System.Web.UI.WebControls.TableItemStyle" /> object.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.AlternatingItemStyle%2A> property to provide a custom style for the alternating items in the <xref:System.Web.UI.WebControls.DataList> control. Common style attributes that can be adjusted include foreground color, background color, font, and content alignment within the cell. Providing a different style enhances the appearance of the <xref:System.Web.UI.WebControls.DataList> control.
Item style properties in the <xref:System.Web.UI.WebControls.DataList> control are inherited from one item style property to another through a hierarchy. Item style properties set lower in the hierarchy are inherited by item style properties higher in the hierarchy. For example, if you specify a red font for the <xref:System.Web.UI.WebControls.DataList.ItemStyle%2A> property, all other item style properties in the <xref:System.Web.UI.WebControls.DataList> control will also have a red font. This allows you to provide a common appearance for the control by setting a single item style property. You can override the inherited style settings for an item style property that is higher in the hierarchy by setting its style properties. For example, you can specify a blue font for the <xref:System.Web.UI.WebControls.DataList.AlternatingItemStyle%2A> property, overriding the red font specified in the <xref:System.Web.UI.WebControls.DataList.ItemStyle%2A> property. The following table lists the hierarchy order from highest to lowest.
|Precedence|Style property|
|----------------|--------------------|
|1|<xref:System.Web.UI.WebControls.DataList.EditItemStyle%2A>|
|2|<xref:System.Web.UI.WebControls.DataList.SelectedItemStyle%2A>|
|3|<xref:System.Web.UI.WebControls.DataList.AlternatingItemStyle%2A>|
|4|<xref:System.Web.UI.WebControls.DataList.ItemStyle%2A>|
|5|<xref:System.Web.UI.WebControls.WebControl.ControlStyle%2A>|
To specify a custom style for the alternating items, place the `<AlternatingItemStyle>` tags between the opening and closing tags of the <xref:System.Web.UI.WebControls.DataList> control. You can then list the style attributes within the opening `<AlternatingItemStyle>` tag.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.AlternatingItemStyle%2A> property to specify a different background color for alternating items in the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListItemStyle#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemStyle/CS/datalistitemstylecs.aspx#1)]
[!code-aspx-vb[DataListItemStyle#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemStyle/VB/datalistitemstylevb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.TableItemStyle" />
<altmember cref="T:System.Web.UI.WebControls.Style" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="AlternatingItemTemplate">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.ITemplate AlternatingItemTemplate { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.ITemplate AlternatingItemTemplate" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.AlternatingItemTemplate" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property AlternatingItemTemplate As ITemplate" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::ITemplate ^ AlternatingItemTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };" />
<MemberSignature Language="F#" Value="member this.AlternatingItemTemplate : System.Web.UI.ITemplate with get, set" Usage="System.Web.UI.WebControls.DataList.AlternatingItemTemplate" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.Browsable(false)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(null)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.DataListItem))</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.ITemplate</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the template for alternating items in the <see cref="T:System.Web.UI.WebControls.DataList" />.</summary>
<value>A <see cref="T:System.Web.UI.ITemplate" /> object that contains the template for alternating items in the <see cref="T:System.Web.UI.WebControls.DataList" /> control. The default value is <see langword="null" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.AlternatingItemTemplate%2A> property to control the contents of alternating items in the <xref:System.Web.UI.WebControls.DataList> control. The appearance of alternating items is controlled by the <xref:System.Web.UI.WebControls.DataList.AlternatingItemStyle%2A> property.
To specify a template for the alternating items, place the `<AlternatingItemTemplate>` tags between the opening and closing tags of the <xref:System.Web.UI.WebControls.DataList> control. You can then list the contents of the template between the opening and closing `<AlternatingItemTemplate>` tags.
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.AlternatingItemTemplate%2A> property to control the contents of alternating items in the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListAlternatingItemTemplate#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListAlternatingItemTemplate/CS/datalistaltitemtemplatecs.aspx#1)]
[!code-aspx-vb[DataListAlternatingItemTemplate#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListAlternatingItemTemplate/VB/datalistaltitemtemplatevb.aspx#1)]
]]></format>
</remarks>
<altmember cref="P:System.Web.UI.WebControls.DataList.AlternatingItemStyle" />
<altmember cref="P:System.Web.UI.WebControls.DataList.ItemTemplate" />
<altmember cref="T:System.Web.UI.ITemplate" />
<related type="Article" href="https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8">Securing Standard Controls</related>
<related type="Article" href="https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b">How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings</related>
<related type="Article" href="https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461">Introduction to Validating User Input in ASP.NET Web Pages</related>
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="CancelCommand">
<MemberSignature Language="C#" Value="public event System.Web.UI.WebControls.DataListCommandEventHandler CancelCommand;" />
<MemberSignature Language="ILAsm" Value=".event class System.Web.UI.WebControls.DataListCommandEventHandler CancelCommand" />
<MemberSignature Language="DocId" Value="E:System.Web.UI.WebControls.DataList.CancelCommand" />
<MemberSignature Language="VB.NET" Value="Public Custom Event CancelCommand As DataListCommandEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:&#xA; event System::Web::UI::WebControls::DataListCommandEventHandler ^ CancelCommand;" />
<MemberSignature Language="F#" Value="member this.CancelCommand : System.Web.UI.WebControls.DataListCommandEventHandler " Usage="member this.CancelCommand : System.Web.UI.WebControls.DataListCommandEventHandler " />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.DataListCommandEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs when the <see langword="Cancel" /> button is clicked for an item in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.CancelCommand> event is raised when the `Cancel` button is clicked for an item in the <xref:System.Web.UI.WebControls.DataList> control.
A typical handler for the <xref:System.Web.UI.WebControls.DataList.CancelCommand> event sets the <xref:System.Web.UI.WebControls.DataList.EditItemIndex%2A> property to `-1` (to deselect the item) and then rebinds the data to the <xref:System.Web.UI.WebControls.DataList> control.
> [!CAUTION]
> Text is not HTML encoded before it is displayed in the <xref:System.Web.UI.WebControls.DataList> control. This makes it possible to embed script within HTML tags in the text. If the values for the control come from user input, be sure to validate the values to reduce security vulnerabilities.
For more information about handling events, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.CancelCommand> event. It cancels any edits made to an item in the <xref:System.Web.UI.WebControls.DataList> control when the `Cancel` button is clicked.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListEdit#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit/CS/datalisteditcs.aspx#1)]
[!code-aspx-vb[DataListEdit#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit/VB/datalisteditvb.aspx#1)]
[!code-aspx-csharp[DataListEdit2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit2/CS/datalistedit2cs.aspx#1)]
[!code-aspx-vb[DataListEdit2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit2/VB/datalistedit2vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.DataListCommandEventHandler" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnCancelCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="E:System.Web.UI.WebControls.DataList.DeleteCommand" />
<altmember cref="E:System.Web.UI.WebControls.DataList.EditCommand" />
<altmember cref="E:System.Web.UI.WebControls.DataList.UpdateCommand" />
<related type="Article" href="https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8">Securing Standard Controls</related>
<related type="Article" href="https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b">How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings</related>
<related type="Article" href="https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461">Introduction to Validating User Input in ASP.NET Web Pages</related>
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="CancelCommandName">
<MemberSignature Language="C#" Value="public const string CancelCommandName;" />
<MemberSignature Language="ILAsm" Value=".field public static literal string CancelCommandName" />
<MemberSignature Language="DocId" Value="F:System.Web.UI.WebControls.DataList.CancelCommandName" />
<MemberSignature Language="VB.NET" Value="Public Const CancelCommandName As String " />
<MemberSignature Language="C++ CLI" Value="public: System::String ^ CancelCommandName;" />
<MemberSignature Language="F#" Value="val mutable CancelCommandName : string" Usage="System.Web.UI.WebControls.DataList.CancelCommandName" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Represents the <see langword="Cancel" /> command name. This field is read-only.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.CancelCommandName> field to represent the `Cancel` command name.
]]></format>
</remarks>
<altmember cref="F:System.Web.UI.WebControls.DataList.SelectCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.EditCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.DeleteCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.UpdateCommandName" />
</Docs>
</Member>
<Member MemberName="CreateControlHierarchy">
<MemberSignature Language="C#" Value="protected override void CreateControlHierarchy (bool useDataSource);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void CreateControlHierarchy(bool useDataSource) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.CreateControlHierarchy(System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Sub CreateControlHierarchy (useDataSource As Boolean)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override void CreateControlHierarchy(bool useDataSource);" />
<MemberSignature Language="F#" Value="override this.CreateControlHierarchy : bool -&gt; unit" Usage="dataList.CreateControlHierarchy useDataSource" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="useDataSource" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="useDataSource">
<see langword="true" /> to use the control's data source; <see langword="false" /> to indicate that the control is being recreated from view state and should not be data-bound.</param>
<summary>Creates the control hierarchy that is used to render the data list control, with or without the specified data source.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.CreateControlHierarchy%2A> method is used primarily by control developers when deriving a custom implementation from the <xref:System.Web.UI.WebControls.DataList> control.
The <xref:System.Web.UI.WebControls.DataList.CreateControlHierarchy%2A> method uses the <xref:System.Web.UI.WebControls.DataList.CreateItem%2A> and <xref:System.Web.UI.WebControls.DataList.InitializeItem%2A> methods to create <xref:System.Web.UI.WebControls.DataListItem> controls that represent the header, footer, separator, and data-bound items contained in the data list. You can access the data-bound items for the data list through the <xref:System.Web.UI.WebControls.DataList.Items%2A> collection. You can access all item types, including the header, footer, and separator items, through the <xref:System.Web.UI.WebControls.BaseDataList.Controls%2A> collection.
Override the <xref:System.Web.UI.WebControls.DataList.CreateControlHierarchy%2A> method to customize how <xref:System.Web.UI.WebControls.DataListItem> controls are created or added to the <xref:System.Web.UI.WebControls.DataList> control. Override the <xref:System.Web.UI.WebControls.DataList.InitializeItem%2A> method to customize templates for a <xref:System.Web.UI.WebControls.DataListItem> control.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="CreateControlStyle">
<MemberSignature Language="C#" Value="protected override System.Web.UI.WebControls.Style CreateControlStyle ();" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance class System.Web.UI.WebControls.Style CreateControlStyle() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.CreateControlStyle" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Function CreateControlStyle () As Style" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override System::Web::UI::WebControls::Style ^ CreateControlStyle();" />
<MemberSignature Language="F#" Value="override this.CreateControlStyle : unit -&gt; System.Web.UI.WebControls.Style" Usage="dataList.CreateControlStyle " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.Style</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Creates the default style object that is used internally by the <see cref="T:System.Web.UI.WebControls.DataList" /> control to implement all style related properties.</summary>
<returns>A <see cref="T:System.Web.UI.WebControls.TableStyle" /> that contains the default style properties for the control.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.CreateControlStyle%2A> method is used primarily by control developers in deriving a custom implementation from the <xref:System.Web.UI.WebControls.DataList> control.
## Examples
The following code example demonstrates how to override the <xref:System.Web.UI.WebControls.DataList.CreateControlStyle%2A> method in a custom server control so that it always displays horizontal grid lines with no cell spacing in the <xref:System.Web.UI.WebControls.DataList> control.
[!code-aspx-csharp[CustomDataListCreateControlStyle#1](~/samples/snippets/csharp/VS_Snippets_WebNet/CustomDataListCreateControlStyle/CS/custom_datalist_createcontrolstylecs.aspx#1)]
[!code-aspx-vb[CustomDataListCreateControlStyle#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/CustomDataListCreateControlStyle/VB/custom_datalist_createcontrolstylevb.aspx#1)]
[!code-csharp[CustomDataListCreateControlStyle#2](~/samples/snippets/csharp/VS_Snippets_WebNet/CustomDataListCreateControlStyle/CS/custom_datalist_createcontrolstyle.cs#2)]
[!code-vb[CustomDataListCreateControlStyle#2](~/samples/snippets/visualbasic/VS_Snippets_WebNet/CustomDataListCreateControlStyle/VB/custom_datalist_createcontrolstyle.vb#2)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="CreateItem">
<MemberSignature Language="C#" Value="protected virtual System.Web.UI.WebControls.DataListItem CreateItem (int itemIndex, System.Web.UI.WebControls.ListItemType itemType);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance class System.Web.UI.WebControls.DataListItem CreateItem(int32 itemIndex, valuetype System.Web.UI.WebControls.ListItemType itemType) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.CreateItem(System.Int32,System.Web.UI.WebControls.ListItemType)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Function CreateItem (itemIndex As Integer, itemType As ListItemType) As DataListItem" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual System::Web::UI::WebControls::DataListItem ^ CreateItem(int itemIndex, System::Web::UI::WebControls::ListItemType itemType);" />
<MemberSignature Language="F#" Value="abstract member CreateItem : int * System.Web.UI.WebControls.ListItemType -&gt; System.Web.UI.WebControls.DataListItem&#xA;override this.CreateItem : int * System.Web.UI.WebControls.ListItemType -&gt; System.Web.UI.WebControls.DataListItem" Usage="dataList.CreateItem (itemIndex, itemType)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.DataListItem</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="itemIndex" Type="System.Int32" />
<Parameter Name="itemType" Type="System.Web.UI.WebControls.ListItemType" />
</Parameters>
<Docs>
<param name="itemIndex">The specified location within the <see cref="T:System.Web.UI.WebControls.DataList" /> to place the created item.</param>
<param name="itemType">A <see cref="T:System.Web.UI.WebControls.ListItemType" /> that represents the specified type of the item to create.</param>
<summary>Creates a <see cref="T:System.Web.UI.WebControls.DataListItem" /> object.</summary>
<returns>A new <see cref="T:System.Web.UI.WebControls.DataListItem" /> created with the specified list-item type.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.CreateItem%2A> method is used primarily by control developers in creating a custom implementation of the <xref:System.Web.UI.WebControls.DataList> control. The <xref:System.Web.UI.WebControls.DataList.CreateItem%2A> method is functionally equivalent to calling the <xref:System.Web.UI.WebControls.DataListItem.%23ctor%2A> constructor for a <xref:System.Web.UI.WebControls.DataListItem>. The <xref:System.Web.UI.WebControls.DataListItem.ItemIndex%2A> and <xref:System.Web.UI.WebControls.DataListItem.ItemType%2A> properties are initialized for the new <xref:System.Web.UI.WebControls.DataListItem> using the specified values, but the item is not inserted into the <xref:System.Web.UI.WebControls.DataList>.
The <xref:System.Web.UI.WebControls.DataList.CreateControlHierarchy%2A> method uses the <xref:System.Web.UI.WebControls.DataList.CreateItem%2A> and <xref:System.Web.UI.WebControls.DataList.InitializeItem%2A> methods to create <xref:System.Web.UI.WebControls.DataListItem> controls that represent the header, footer, separator, and data-bound items contained in the data list. You can access the data-bound items for the data list through the <xref:System.Web.UI.WebControls.DataList.Items%2A> collection. You can access all item types, including the header, footer, and separator items, through the <xref:System.Web.UI.WebControls.BaseDataList.Controls%2A> collection.
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>Override this method to create your own derived <see cref="T:System.Web.UI.WebControls.DataListItem" /> type, or to set additional member properties when a <see cref="T:System.Web.UI.WebControls.DataListItem" /> is created.</para>
</block>
<altmember cref="M:System.Web.UI.WebControls.DataList.CreateControlHierarchy(System.Boolean)" />
<altmember cref="M:System.Web.UI.WebControls.DataList.InitializeItem(System.Web.UI.WebControls.DataListItem)" />
</Docs>
</Member>
<Member MemberName="DeleteCommand">
<MemberSignature Language="C#" Value="public event System.Web.UI.WebControls.DataListCommandEventHandler DeleteCommand;" />
<MemberSignature Language="ILAsm" Value=".event class System.Web.UI.WebControls.DataListCommandEventHandler DeleteCommand" />
<MemberSignature Language="DocId" Value="E:System.Web.UI.WebControls.DataList.DeleteCommand" />
<MemberSignature Language="VB.NET" Value="Public Custom Event DeleteCommand As DataListCommandEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:&#xA; event System::Web::UI::WebControls::DataListCommandEventHandler ^ DeleteCommand;" />
<MemberSignature Language="F#" Value="member this.DeleteCommand : System.Web.UI.WebControls.DataListCommandEventHandler " Usage="member this.DeleteCommand : System.Web.UI.WebControls.DataListCommandEventHandler " />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.DataListCommandEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs when the <see langword="Delete" /> button is clicked for an item in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.DeleteCommand> event is raised when the `Delete` button is clicked for an item in the <xref:System.Web.UI.WebControls.DataList> control.
A typical handler for the <xref:System.Web.UI.WebControls.DataList.DeleteCommand> event removes the selected item from the data source and then rebinds the data to the <xref:System.Web.UI.WebControls.DataList> control.
For more information about handling events, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.DeleteCommand> event. It deletes the selected item in the <xref:System.Web.UI.WebControls.DataList> control when the `Delete` button is clicked.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListEdit#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit/CS/datalisteditcs.aspx#1)]
[!code-aspx-vb[DataListEdit#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit/VB/datalisteditvb.aspx#1)]
[!code-aspx-csharp[DataListEdit2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit2/CS/datalistedit2cs.aspx#1)]
[!code-aspx-vb[DataListEdit2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit2/VB/datalistedit2vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.DataListCommandEventHandler" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnDeleteCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="E:System.Web.UI.WebControls.DataList.CancelCommand" />
<altmember cref="E:System.Web.UI.WebControls.DataList.EditCommand" />
<altmember cref="E:System.Web.UI.WebControls.DataList.UpdateCommand" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="DeleteCommandName">
<MemberSignature Language="C#" Value="public const string DeleteCommandName;" />
<MemberSignature Language="ILAsm" Value=".field public static literal string DeleteCommandName" />
<MemberSignature Language="DocId" Value="F:System.Web.UI.WebControls.DataList.DeleteCommandName" />
<MemberSignature Language="VB.NET" Value="Public Const DeleteCommandName As String " />
<MemberSignature Language="C++ CLI" Value="public: System::String ^ DeleteCommandName;" />
<MemberSignature Language="F#" Value="val mutable DeleteCommandName : string" Usage="System.Web.UI.WebControls.DataList.DeleteCommandName" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Represents the <see langword="Delete" /> command name. This field is read-only.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.DeleteCommandName> field to represent the `Delete` command name.
]]></format>
</remarks>
<altmember cref="F:System.Web.UI.WebControls.DataList.SelectCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.EditCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.UpdateCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.CancelCommandName" />
</Docs>
</Member>
<Member MemberName="EditCommand">
<MemberSignature Language="C#" Value="public event System.Web.UI.WebControls.DataListCommandEventHandler EditCommand;" />
<MemberSignature Language="ILAsm" Value=".event class System.Web.UI.WebControls.DataListCommandEventHandler EditCommand" />
<MemberSignature Language="DocId" Value="E:System.Web.UI.WebControls.DataList.EditCommand" />
<MemberSignature Language="VB.NET" Value="Public Custom Event EditCommand As DataListCommandEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:&#xA; event System::Web::UI::WebControls::DataListCommandEventHandler ^ EditCommand;" />
<MemberSignature Language="F#" Value="member this.EditCommand : System.Web.UI.WebControls.DataListCommandEventHandler " Usage="member this.EditCommand : System.Web.UI.WebControls.DataListCommandEventHandler " />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.DataListCommandEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs when the <see langword="Edit" /> button is clicked for an item in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.EditCommand> event is raised when the `Edit` button is clicked for an item in the <xref:System.Web.UI.WebControls.DataList> control.
A typical handler for the <xref:System.Web.UI.WebControls.DataList.EditCommand> event sets the <xref:System.Web.UI.WebControls.DataList.EditItemIndex%2A> property to the selected row and then rebinds the data to the <xref:System.Web.UI.WebControls.DataList> control.
> [!CAUTION]
> Text is not HTML encoded before it is displayed in the <xref:System.Web.UI.WebControls.DataList> control. This makes it possible to embed script within HTML tags in the text. If the values for the control come from user input, be sure to validate the values to reduce security vulnerabilities.
For more information about handling events, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.EditCommand> event. It allows you to edit the selected item in the <xref:System.Web.UI.WebControls.DataList> control when the `Edit` button is clicked.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListEdit#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit/CS/datalisteditcs.aspx#1)]
[!code-aspx-vb[DataListEdit#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit/VB/datalisteditvb.aspx#1)]
[!code-aspx-csharp[DataListEdit2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit2/CS/datalistedit2cs.aspx#1)]
[!code-aspx-vb[DataListEdit2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit2/VB/datalistedit2vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.DataListCommandEventHandler" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnEditCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="E:System.Web.UI.WebControls.DataList.CancelCommand" />
<altmember cref="E:System.Web.UI.WebControls.DataList.DeleteCommand" />
<altmember cref="E:System.Web.UI.WebControls.DataList.UpdateCommand" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="EditCommandName">
<MemberSignature Language="C#" Value="public const string EditCommandName;" />
<MemberSignature Language="ILAsm" Value=".field public static literal string EditCommandName" />
<MemberSignature Language="DocId" Value="F:System.Web.UI.WebControls.DataList.EditCommandName" />
<MemberSignature Language="VB.NET" Value="Public Const EditCommandName As String " />
<MemberSignature Language="C++ CLI" Value="public: System::String ^ EditCommandName;" />
<MemberSignature Language="F#" Value="val mutable EditCommandName : string" Usage="System.Web.UI.WebControls.DataList.EditCommandName" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Represents the <see langword="Edit" /> command name. This field is read-only.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.EditCommandName> field to represent the `Edit` command name.
]]></format>
</remarks>
<altmember cref="F:System.Web.UI.WebControls.DataList.SelectCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.DeleteCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.UpdateCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.CancelCommandName" />
</Docs>
</Member>
<Member MemberName="EditItemIndex">
<MemberSignature Language="C#" Value="public virtual int EditItemIndex { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 EditItemIndex" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.EditItemIndex" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property EditItemIndex As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property int EditItemIndex { int get(); void set(int value); };" />
<MemberSignature Language="F#" Value="member this.EditItemIndex : int with get, set" Usage="System.Web.UI.WebControls.DataList.EditItemIndex" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(-1)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the index number of the selected item in the <see cref="T:System.Web.UI.WebControls.DataList" /> control to edit.</summary>
<value>The index number of the selected item in the <see cref="T:System.Web.UI.WebControls.DataList" /> control to edit.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.EditItemIndex%2A> property to programmatically specify the item to edit. You can also use this property to determine the index of the item selected for editing.
> [!NOTE]
> The <xref:System.Web.UI.WebControls.DataList.EditItemIndex%2A> property is zero based.
To unselect an item, set the <xref:System.Web.UI.WebControls.DataList.EditItemIndex%2A> property to `-1`.
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
The <xref:System.Web.UI.WebControls.DataList.EditItemIndex%2A> property is stored in control state.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.EditItemIndex%2A> property to specify the item selected by the user for editing.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListEdit#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit/CS/datalisteditcs.aspx#1)]
[!code-aspx-vb[DataListEdit#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit/VB/datalisteditvb.aspx#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">The selected value is less than <see langword="0" />.</exception>
<altmember cref="P:System.Web.UI.WebControls.DataList.EditItemStyle" />
<altmember cref="P:System.Web.UI.WebControls.DataList.EditItemTemplate" />
<altmember cref="E:System.Web.UI.WebControls.DataList.EditCommand" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnEditCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="EditItemStyle">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.WebControls.TableItemStyle EditItemStyle { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.TableItemStyle EditItemStyle" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.EditItemStyle" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property EditItemStyle As TableItemStyle" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::WebControls::TableItemStyle ^ EditItemStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };" />
<MemberSignature Language="F#" Value="member this.EditItemStyle : System.Web.UI.WebControls.TableItemStyle" Usage="System.Web.UI.WebControls.DataList.EditItemStyle" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(null)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.NotifyParentProperty(true)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.TableItemStyle</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the style properties for the item selected for editing in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<value>A <see cref="T:System.Web.UI.WebControls.TableItemStyle" /> object that contains the style properties for the item selected for editing in the <see cref="T:System.Web.UI.WebControls.DataList" /> control. The default value is an empty <see cref="T:System.Web.UI.WebControls.TableItemStyle" /> object.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.EditItemStyle%2A> property to provide a custom style for the item selected for editing in the <xref:System.Web.UI.WebControls.DataList> control. Common style attributes that can be adjusted include foreground color, background color, font, and content alignment within the cell. Providing a different style enhances the appearance of the <xref:System.Web.UI.WebControls.DataList> control.
Item style properties in the <xref:System.Web.UI.WebControls.DataList> control are inherited from one item style property to another through a hierarchy. Item style properties set lower in the hierarchy are inherited by item style properties higher in the hierarchy. For example, if you specify a red font for the <xref:System.Web.UI.WebControls.DataList.ItemStyle%2A> property, all other item style properties in the <xref:System.Web.UI.WebControls.DataList> control will also have a red font. This allows you to provide a common appearance for the control by setting a single item style property. You can override the inherited style settings for an item style property that is higher in the hierarchy by setting its style properties. For example, you can specify a blue font for the <xref:System.Web.UI.WebControls.DataList.AlternatingItemStyle%2A> property, overriding the red font specified in the <xref:System.Web.UI.WebControls.DataList.ItemStyle%2A> property. The following table lists the hierarchy order from highest to lowest.
|Precedence|Style Property|
|----------------|--------------------|
|1|<xref:System.Web.UI.WebControls.DataList.EditItemStyle%2A>|
|2|<xref:System.Web.UI.WebControls.DataList.SelectedItemStyle%2A>|
|3|<xref:System.Web.UI.WebControls.DataList.AlternatingItemStyle%2A>|
|4|<xref:System.Web.UI.WebControls.DataList.ItemStyle%2A>|
|5|<xref:System.Web.UI.WebControls.WebControl.ControlStyle%2A>|
To specify a custom style for the item selected for editing, place the `<EditItemStyle>` tags between the opening and closing tags of the <xref:System.Web.UI.WebControls.DataList> control. You can then list the style attributes within the opening `<EditItemStyle>` tag.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.EditItemStyle%2A> property to specify a different appearance for the item selected by the user for editing.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListEdit#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit/CS/datalisteditcs.aspx#1)]
[!code-aspx-vb[DataListEdit#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit/VB/datalisteditvb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.TableItemStyle" />
<altmember cref="T:System.Web.UI.WebControls.Style" />
<altmember cref="P:System.Web.UI.WebControls.DataList.EditItemIndex" />
<altmember cref="P:System.Web.UI.WebControls.DataList.EditItemTemplate" />
<altmember cref="E:System.Web.UI.WebControls.DataList.EditCommand" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnEditCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="EditItemTemplate">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.ITemplate EditItemTemplate { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.ITemplate EditItemTemplate" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.EditItemTemplate" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property EditItemTemplate As ITemplate" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::ITemplate ^ EditItemTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };" />
<MemberSignature Language="F#" Value="member this.EditItemTemplate : System.Web.UI.ITemplate with get, set" Usage="System.Web.UI.WebControls.DataList.EditItemTemplate" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.Browsable(false)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(null)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.DataListItem))</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.ITemplate</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the template for the item selected for editing in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<value>A <see cref="T:System.Web.UI.ITemplate" /> object that contains the template for the item selected for editing in the <see cref="T:System.Web.UI.WebControls.DataList" /> control. The default value is <see langword="null" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.EditItemTemplate%2A> property to control the contents of the item selected for editing in the <xref:System.Web.UI.WebControls.DataList> control. The appearance of the item selected for editing is controlled by the <xref:System.Web.UI.WebControls.DataList.EditItemStyle%2A> property.
To specify a template for the item selected for editing, place the `<EditItemTemplate>` tags between the opening and closing tags of the <xref:System.Web.UI.WebControls.DataList> control. You can then list the contents of the template between the opening and closing `<EditItemTemplate>` tags.
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.EditItemTemplate%2A> property to control the contents of the item selected by the user for editing.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListEdit#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit/CS/datalisteditcs.aspx#1)]
[!code-aspx-vb[DataListEdit#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit/VB/datalisteditvb.aspx#1)]
]]></format>
</remarks>
<altmember cref="P:System.Web.UI.WebControls.DataList.EditItemIndex" />
<altmember cref="P:System.Web.UI.WebControls.DataList.EditItemStyle" />
<altmember cref="E:System.Web.UI.WebControls.DataList.EditCommand" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnEditCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="T:System.Web.UI.ITemplate" />
<related type="Article" href="https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8">Securing Standard Controls</related>
<related type="Article" href="https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b">How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings</related>
<related type="Article" href="https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461">Introduction to Validating User Input in ASP.NET Web Pages</related>
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="ExtractTemplateRows">
<MemberSignature Language="C#" Value="public virtual bool ExtractTemplateRows { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool ExtractTemplateRows" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.ExtractTemplateRows" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property ExtractTemplateRows As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property bool ExtractTemplateRows { bool get(); void set(bool value); };" />
<MemberSignature Language="F#" Value="member this.ExtractTemplateRows : bool with get, set" Usage="System.Web.UI.WebControls.DataList.ExtractTemplateRows" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(false)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value that indicates whether the rows of a <see cref="T:System.Web.UI.WebControls.Table" /> control, defined in each template of a <see cref="T:System.Web.UI.WebControls.DataList" /> control, are extracted and displayed.</summary>
<value>
<see langword="true" /> if the rows of a <see cref="T:System.Web.UI.WebControls.Table" /> control, defined in each template of a <see cref="T:System.Web.UI.WebControls.DataList" /> control, are extracted and displayed; otherwise, <see langword="false" />. The default value is <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The contents of the <xref:System.Web.UI.WebControls.DataList> control are specified by using templates. Normally, you list controls that you want to display in the templates. You can also place a <xref:System.Web.UI.WebControls.Table> control in a template and display the rows of the table.
Use the <xref:System.Web.UI.WebControls.DataList.ExtractTemplateRows%2A> property to specify whether the rows of a <xref:System.Web.UI.WebControls.Table> control defined in each template of a <xref:System.Web.UI.WebControls.DataList> control are extracted and displayed. All rows extracted from the templates of the <xref:System.Web.UI.WebControls.DataList> control are displayed in a single table. This allows you to create a single table from other smaller tables and still maintain the features of the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> When this property is set to `true`, you must provide a well-formed <xref:System.Web.UI.WebControls.Table> control for each template you want to include in the <xref:System.Web.UI.WebControls.DataList> control. Only the rows of the tables will be displayed. All other content in the template will be ignored. You must use a <xref:System.Web.UI.WebControls.Table> control for this feature to work properly. The <xref:System.Web.UI.HtmlControls.HtmlTable?displayProperty=nameWithType> control is not compatible with this property.
When you create a cell for a <xref:System.Web.UI.WebControls.Table> control in a template, you can use the <xref:System.Web.UI.WebControls.TableCell.ColumnSpan%2A> property of the <xref:System.Web.UI.WebControls.TableCell> object to control the number of columns the cell spans. You can also use the <xref:System.Web.UI.WebControls.TableCell.RowSpan%2A> property to control the number of rows the cell spans.
> [!NOTE]
> The <xref:System.Web.UI.WebControls.DataList.RepeatColumns%2A>, <xref:System.Web.UI.WebControls.DataList.RepeatDirection%2A>, and <xref:System.Web.UI.WebControls.DataList.RepeatLayout%2A> properties do not affect the appearance of the <xref:System.Web.UI.WebControls.DataList> control when this property is set to `true`.
## Examples
The following code example demonstrate how to use the <xref:System.Web.UI.WebControls.DataList.ExtractTemplateRows%2A> property to extract and display the rows of <xref:System.Web.UI.WebControls.Table> controls defined in the templates of the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[Classic DataList.ExtractTemplateRows Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic DataList.ExtractTemplateRows Example/CS/sourcecs.aspx#1)]
[!code-aspx-vb[Classic DataList.ExtractTemplateRows Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic DataList.ExtractTemplateRows Example/VB/sourcevb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.Table" />
<altmember cref="T:System.Web.UI.WebControls.TableRow" />
<altmember cref="T:System.Web.UI.WebControls.TableCell" />
<altmember cref="P:System.Web.UI.WebControls.DataList.AlternatingItemTemplate" />
<altmember cref="P:System.Web.UI.WebControls.DataList.EditItemTemplate" />
<altmember cref="P:System.Web.UI.WebControls.DataList.FooterTemplate" />
<altmember cref="P:System.Web.UI.WebControls.DataList.HeaderTemplate" />
<altmember cref="P:System.Web.UI.WebControls.DataList.ItemTemplate" />
<altmember cref="P:System.Web.UI.WebControls.DataList.SelectedItemTemplate" />
<altmember cref="P:System.Web.UI.WebControls.DataList.SeparatorTemplate" />
</Docs>
</Member>
<Member MemberName="FooterStyle">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.WebControls.TableItemStyle FooterStyle { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.TableItemStyle FooterStyle" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.FooterStyle" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property FooterStyle As TableItemStyle" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::WebControls::TableItemStyle ^ FooterStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };" />
<MemberSignature Language="F#" Value="member this.FooterStyle : System.Web.UI.WebControls.TableItemStyle" Usage="System.Web.UI.WebControls.DataList.FooterStyle" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(null)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.NotifyParentProperty(true)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.TableItemStyle</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the style properties for the footer section of the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<value>A <see cref="T:System.Web.UI.WebControls.TableItemStyle" /> object that contains the style properties for the footer section of the <see cref="T:System.Web.UI.WebControls.DataList" /> control. The default value is an empty <see cref="T:System.Web.UI.WebControls.TableItemStyle" /> object.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use this property to provide a custom style for the footer section of the <xref:System.Web.UI.WebControls.DataList> control. Common style attributes that can be adjusted include foreground color, background color, font, and content alignment within the cell. Providing a different style enhances the appearance of the <xref:System.Web.UI.WebControls.DataList> control.
The <xref:System.Web.UI.WebControls.DataList.FooterStyle%2A> property of the <xref:System.Web.UI.WebControls.DataList> control inherits the style settings of the <xref:System.Web.UI.WebControls.WebControl.ControlStyle%2A> property. For example, if you specify a red font for the <xref:System.Web.UI.WebControls.WebControl.ControlStyle%2A> property, the <xref:System.Web.UI.WebControls.DataList.FooterStyle%2A> property will also have a red font. This allows you to provide a common appearance for the control by setting a single style property. You can override the inherited style settings by setting the <xref:System.Web.UI.WebControls.DataList.FooterStyle%2A> property. For example, you can specify a blue font for the <xref:System.Web.UI.WebControls.DataList.FooterStyle%2A> property, overriding the red font specified in the <xref:System.Web.UI.WebControls.WebControl.ControlStyle%2A> property.
To specify a custom style for the footer section, place the `<FooterStyle>` tags between the opening and closing tags of the <xref:System.Web.UI.WebControls.DataList> control. You can then list the style attributes within the opening `<FooterStyle>` tag.
> [!NOTE]
> The <xref:System.Web.UI.WebControls.DataList.ShowFooter%2A> property must be set to `true` for this property to be visible.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.FooterStyle%2A> property to specify a custom background color for the footer section of the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListHeaderStyle#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListHeaderStyle/CS/datalistheaderstylecs.aspx#1)]
[!code-aspx-vb[DataListHeaderStyle#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListHeaderStyle/VB/datalistheaderstylevb.aspx#1)]
]]></format>
</remarks>
<altmember cref="P:System.Web.UI.WebControls.DataList.FooterTemplate" />
<altmember cref="P:System.Web.UI.WebControls.DataGrid.ShowFooter" />
<altmember cref="T:System.Web.UI.WebControls.TableItemStyle" />
<altmember cref="T:System.Web.UI.WebControls.Style" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="FooterTemplate">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.ITemplate FooterTemplate { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.ITemplate FooterTemplate" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.FooterTemplate" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property FooterTemplate As ITemplate" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::ITemplate ^ FooterTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };" />
<MemberSignature Language="F#" Value="member this.FooterTemplate : System.Web.UI.ITemplate with get, set" Usage="System.Web.UI.WebControls.DataList.FooterTemplate" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.Browsable(false)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(null)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.DataListItem))</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.ITemplate</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the template for the footer section of the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<value>A <see cref="T:System.Web.UI.ITemplate" /> object that contains the template for the footer section of the <see cref="T:System.Web.UI.WebControls.DataList" /> control. The default value is <see langword="null" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.FooterTemplate%2A> property to control the contents of the footer section. The appearance of the footer section is controlled by the <xref:System.Web.UI.WebControls.DataList.FooterStyle%2A> property.
> [!NOTE]
> The <xref:System.Web.UI.WebControls.DataList.ShowFooter%2A> property must be set to `true` for this property to be visible.
The <xref:System.Web.UI.WebControls.DataList.HeaderStyle%2A> property of the <xref:System.Web.UI.WebControls.DataList> control inherits the style settings of the <xref:System.Web.UI.WebControls.WebControl.ControlStyle%2A> property. For example, if you specify a red font for the <xref:System.Web.UI.WebControls.WebControl.ControlStyle%2A> property, the <xref:System.Web.UI.WebControls.DataList.HeaderStyle%2A> property will also have a red font. This allows you to provide a common appearance for the control by setting a single style property. You can override the inherited style settings by setting the <xref:System.Web.UI.WebControls.DataList.HeaderStyle%2A> property. For example, you can specify a blue font for the <xref:System.Web.UI.WebControls.DataList.HeaderStyle%2A> property, overriding the red font specified in the <xref:System.Web.UI.WebControls.WebControl.ControlStyle%2A> property.
To specify a template for the footer section, place the `<FooterTemplate>` tags between the opening and closing tags of the <xref:System.Web.UI.WebControls.DataList> control. You can then list the contents of the template between the opening and closing `<FooterTemplate>` tags.
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.FooterTemplate%2A> property to control the contents of the footer section of the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListHeaderStyle#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListHeaderStyle/CS/datalistheaderstylecs.aspx#1)]
[!code-aspx-vb[DataListHeaderStyle#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListHeaderStyle/VB/datalistheaderstylevb.aspx#1)]
]]></format>
</remarks>
<altmember cref="P:System.Web.UI.WebControls.DataList.FooterStyle" />
<altmember cref="P:System.Web.UI.WebControls.DataList.ShowFooter" />
<altmember cref="T:System.Web.UI.ITemplate" />
<related type="Article" href="https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8">Securing Standard Controls</related>
<related type="Article" href="https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b">How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings</related>
<related type="Article" href="https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461">Introduction to Validating User Input in ASP.NET Web Pages</related>
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="GridLines">
<MemberSignature Language="C#" Value="public override System.Web.UI.WebControls.GridLines GridLines { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Web.UI.WebControls.GridLines GridLines" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.GridLines" />
<MemberSignature Language="VB.NET" Value="Public Overrides Property GridLines As GridLines" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::WebControls::GridLines GridLines { System::Web::UI::WebControls::GridLines get(); void set(System::Web::UI::WebControls::GridLines value); };" />
<MemberSignature Language="F#" Value="member this.GridLines : System.Web.UI.WebControls.GridLines with get, set" Usage="System.Web.UI.WebControls.DataList.GridLines" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(Mono.Cecil.CustomAttributeArgument)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.GridLines</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the grid line style for the <see cref="T:System.Web.UI.WebControls.DataList" /> control when the <see cref="P:System.Web.UI.WebControls.DataList.RepeatLayout" /> property is set to <see langword="RepeatLayout.Table" />.</summary>
<value>One of the <see cref="T:System.Web.UI.WebControls.GridLines" /> enumeration values. The default value is <see langword="None" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.GridLines%2A> property to specify the grid line style for the <xref:System.Web.UI.WebControls.DataList> control. The following table lists the possible styles.
|Style|Description|
|-----------|-----------------|
|<xref:System.Web.UI.WebControls.GridLines.None>|No grid lines.|
|<xref:System.Web.UI.WebControls.GridLines.Horizontal>|Displays the horizontal grid lines.|
|<xref:System.Web.UI.WebControls.GridLines.Vertical>|Displays the vertical grid line.|
|<xref:System.Web.UI.WebControls.GridLines.Both>|Displays both the horizontal and vertical grid lines.|
> [!NOTE]
> This property only applies if the <xref:System.Web.UI.WebControls.DataList.RepeatLayout%2A> property is set to `RepeatLayout.Table`.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.GridLines%2A> property to display the vertical and horizontal grid lines of the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListLayout#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListLayout/CS/datalistlayoutcs.aspx#1)]
[!code-aspx-vb[DataListLayout#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListLayout/VB/datalistlayoutvb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.GridLines" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="HeaderStyle">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.WebControls.TableItemStyle HeaderStyle { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.TableItemStyle HeaderStyle" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.HeaderStyle" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property HeaderStyle As TableItemStyle" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::WebControls::TableItemStyle ^ HeaderStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };" />
<MemberSignature Language="F#" Value="member this.HeaderStyle : System.Web.UI.WebControls.TableItemStyle" Usage="System.Web.UI.WebControls.DataList.HeaderStyle" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(null)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.NotifyParentProperty(true)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.TableItemStyle</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the style properties for the heading section of the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<value>A <see cref="T:System.Web.UI.WebControls.TableItemStyle" /> object that contains the style properties for the heading section of the <see cref="T:System.Web.UI.WebControls.DataList" /> control. The default value is an empty <see cref="T:System.Web.UI.WebControls.TableItemStyle" /> object.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use this property to provide a custom style for the heading of the <xref:System.Web.UI.WebControls.DataList> control. Common style attributes that can be adjusted include foreground color, background color, font, and content alignment within the cell. Providing a different style enhances the appearance of the <xref:System.Web.UI.WebControls.DataList> control.
To specify a custom style for the heading section, place the `<HeaderStyle>` tags between the opening and closing tags of the <xref:System.Web.UI.WebControls.DataList> control. You can then list the style attributes within the opening `<HeaderStyle>` tag.
> [!NOTE]
> The <xref:System.Web.UI.WebControls.DataList.ShowHeader%2A> property must be set to `true` for this property to be visible.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.HeaderStyle%2A> property to specify a custom background color for the heading section of the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListHeaderStyle#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListHeaderStyle/CS/datalistheaderstylecs.aspx#1)]
[!code-aspx-vb[DataListHeaderStyle#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListHeaderStyle/VB/datalistheaderstylevb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.TableItemStyle" />
<altmember cref="T:System.Web.UI.WebControls.Style" />
<altmember cref="P:System.Web.UI.WebControls.DataList.FooterTemplate" />
<altmember cref="P:System.Web.UI.WebControls.DataList.ShowHeader" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="HeaderTemplate">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.ITemplate HeaderTemplate { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.ITemplate HeaderTemplate" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.HeaderTemplate" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property HeaderTemplate As ITemplate" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::ITemplate ^ HeaderTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };" />
<MemberSignature Language="F#" Value="member this.HeaderTemplate : System.Web.UI.ITemplate with get, set" Usage="System.Web.UI.WebControls.DataList.HeaderTemplate" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.Browsable(false)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(null)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.DataListItem))</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.ITemplate</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the template for the heading section of the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<value>A <see cref="T:System.Web.UI.ITemplate" /> that contains the template for the heading section of the <see cref="T:System.Web.UI.WebControls.DataList" /> control. The default value is <see langword="null" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.HeaderTemplate%2A> property to control the contents of the heading section. The appearance of the header section is controlled by the <xref:System.Web.UI.WebControls.DataList.HeaderStyle%2A> property.
> [!NOTE]
> The <xref:System.Web.UI.WebControls.DataList.ShowHeader%2A> property must be set to `true` for this property to be visible.
To specify a template for the heading section, place the `<HeaderTemplate>` tags between the opening and closing tags of the <xref:System.Web.UI.WebControls.DataList> control. You can then list the contents of the template between the opening and closing `<HeaderTemplate>` tags.
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.HeaderTemplate%2A> property to control the contents of the heading section of the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListLayout#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListLayout/CS/datalistlayoutcs.aspx#1)]
[!code-aspx-vb[DataListLayout#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListLayout/VB/datalistlayoutvb.aspx#1)]
]]></format>
</remarks>
<altmember cref="P:System.Web.UI.WebControls.DataList.HeaderStyle" />
<altmember cref="T:System.Web.UI.ITemplate" />
<related type="Article" href="https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8">Securing Standard Controls</related>
<related type="Article" href="https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b">How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings</related>
<related type="Article" href="https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461">Introduction to Validating User Input in ASP.NET Web Pages</related>
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="InitializeItem">
<MemberSignature Language="C#" Value="protected virtual void InitializeItem (System.Web.UI.WebControls.DataListItem item);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void InitializeItem(class System.Web.UI.WebControls.DataListItem item) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.InitializeItem(System.Web.UI.WebControls.DataListItem)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub InitializeItem (item As DataListItem)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual void InitializeItem(System::Web::UI::WebControls::DataListItem ^ item);" />
<MemberSignature Language="F#" Value="abstract member InitializeItem : System.Web.UI.WebControls.DataListItem -&gt; unit&#xA;override this.InitializeItem : System.Web.UI.WebControls.DataListItem -&gt; unit" Usage="dataList.InitializeItem item" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="item" Type="System.Web.UI.WebControls.DataListItem" />
</Parameters>
<Docs>
<param name="item">The <see cref="T:System.Web.UI.WebControls.DataListItem" /> to initialize.</param>
<summary>Initializes a <see cref="T:System.Web.UI.WebControls.DataListItem" /> object based on the specified templates and styles for the list-item type.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.InitializeItem%2A> method is used primarily by control developers to extend the <xref:System.Web.UI.WebControls.DataList> control.
The <xref:System.Web.UI.WebControls.DataList.CreateControlHierarchy%2A> method uses the <xref:System.Web.UI.WebControls.DataList.CreateItem%2A> and <xref:System.Web.UI.WebControls.DataList.InitializeItem%2A> methods to create <xref:System.Web.UI.WebControls.DataListItem> controls that represent the header, footer, separator, and data-bound items contained in the data list. You can access the data-bound items for the data list through the <xref:System.Web.UI.WebControls.DataList.Items%2A> collection. You can access all item types, including the header, footer, and separator items, through the <xref:System.Web.UI.WebControls.BaseDataList.Controls%2A> collection.
Override the <xref:System.Web.UI.WebControls.DataList.CreateControlHierarchy%2A> method to customize how <xref:System.Web.UI.WebControls.DataListItem> controls are created or added to the <xref:System.Web.UI.WebControls.DataList> control. Override the <xref:System.Web.UI.WebControls.DataList.InitializeItem%2A> method to customize templates for a <xref:System.Web.UI.WebControls.DataListItem> control.
]]></format>
</remarks>
<altmember cref="M:System.Web.UI.WebControls.DataList.CreateItem(System.Int32,System.Web.UI.WebControls.ListItemType)" />
<altmember cref="T:System.Web.UI.WebControls.ListItemType" />
</Docs>
</Member>
<Member MemberName="ItemCommand">
<MemberSignature Language="C#" Value="public event System.Web.UI.WebControls.DataListCommandEventHandler ItemCommand;" />
<MemberSignature Language="ILAsm" Value=".event class System.Web.UI.WebControls.DataListCommandEventHandler ItemCommand" />
<MemberSignature Language="DocId" Value="E:System.Web.UI.WebControls.DataList.ItemCommand" />
<MemberSignature Language="VB.NET" Value="Public Custom Event ItemCommand As DataListCommandEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:&#xA; event System::Web::UI::WebControls::DataListCommandEventHandler ^ ItemCommand;" />
<MemberSignature Language="F#" Value="member this.ItemCommand : System.Web.UI.WebControls.DataListCommandEventHandler " Usage="member this.ItemCommand : System.Web.UI.WebControls.DataListCommandEventHandler " />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.DataListCommandEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs when any button is clicked in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.ItemCommand> event is raised when any button is clicked in the <xref:System.Web.UI.WebControls.DataList> control and is commonly used when you have a button control with a custom `CommandName` value.
For more information about handling events, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.ItemCommand> event to select an item from the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListItemCommand#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemCommand/CS/datalistitemcommandcs.aspx#1)]
[!code-aspx-vb[DataListItemCommand#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemCommand/VB/datalistitemcommandvb.aspx#1)]
[!code-aspx-csharp[DataListItemCommand2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemCommand2/CS/datalistitemcommand2cs.aspx#1)]
[!code-aspx-vb[DataListItemCommand2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemCommand2/VB/datalistitemcommand2vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.DataListCommandEventHandler" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnItemCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
<related type="Article" href="https://msdn.microsoft.com/library/73bf8638-c4ec-4069-b0bb-a1dc79b92e32"> How to: Consume Events in a Web Forms Application</related>
</Docs>
</Member>
<Member MemberName="ItemCreated">
<MemberSignature Language="C#" Value="public event System.Web.UI.WebControls.DataListItemEventHandler ItemCreated;" />
<MemberSignature Language="ILAsm" Value=".event class System.Web.UI.WebControls.DataListItemEventHandler ItemCreated" />
<MemberSignature Language="DocId" Value="E:System.Web.UI.WebControls.DataList.ItemCreated" />
<MemberSignature Language="VB.NET" Value="Public Custom Event ItemCreated As DataListItemEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:&#xA; event System::Web::UI::WebControls::DataListItemEventHandler ^ ItemCreated;" />
<MemberSignature Language="F#" Value="member this.ItemCreated : System.Web.UI.WebControls.DataListItemEventHandler " Usage="member this.ItemCreated : System.Web.UI.WebControls.DataListItemEventHandler " />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.DataListItemEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs on the server when an item in the <see cref="T:System.Web.UI.WebControls.DataList" /> control is created.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.ItemCreated> event is raised when an item in the <xref:System.Web.UI.WebControls.DataList> control is created, both during round-trips and at the time data is bound to the control.
The <xref:System.Web.UI.WebControls.DataList.ItemCreated> event is commonly used to control the content and appearance of a row in the <xref:System.Web.UI.WebControls.DataList> control.
For more information about handling events, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.ItemCreated> event to display the order in which items in the <xref:System.Web.UI.WebControls.DataList> control are created.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListItemCreated#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemCreated/CS/datalistitemcreatedcs.aspx#1)]
[!code-aspx-vb[DataListItemCreated#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemCreated/VB/datalistitemcreatedvb.aspx#1)]
[!code-aspx-csharp[DataListItemCreated2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemCreated2/CS/datalistitemcreated2cs.aspx#1)]
[!code-aspx-vb[DataListItemCreated2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemCreated2/VB/datalistitemcreated2vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.DataListItemEventHandler" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnItemCreated(System.Web.UI.WebControls.DataListItemEventArgs)" />
<related type="Article" href="https://msdn.microsoft.com/library/73bf8638-c4ec-4069-b0bb-a1dc79b92e32">How to: Consume Events in a Web Forms Application</related>
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="ItemDataBound">
<MemberSignature Language="C#" Value="public event System.Web.UI.WebControls.DataListItemEventHandler ItemDataBound;" />
<MemberSignature Language="ILAsm" Value=".event class System.Web.UI.WebControls.DataListItemEventHandler ItemDataBound" />
<MemberSignature Language="DocId" Value="E:System.Web.UI.WebControls.DataList.ItemDataBound" />
<MemberSignature Language="VB.NET" Value="Public Custom Event ItemDataBound As DataListItemEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:&#xA; event System::Web::UI::WebControls::DataListItemEventHandler ^ ItemDataBound;" />
<MemberSignature Language="F#" Value="member this.ItemDataBound : System.Web.UI.WebControls.DataListItemEventHandler " Usage="member this.ItemDataBound : System.Web.UI.WebControls.DataListItemEventHandler " />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.DataListItemEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs when an item is data bound to the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.ItemDataBound> event is raised after an item is data bound to the <xref:System.Web.UI.WebControls.DataList> control. This event provides you with the last opportunity to access the data item before it is displayed on the client. After this event is raised, the data item is no longer available.
For more information about handling events, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.ItemDataBound> event to display the order in which items in the <xref:System.Web.UI.WebControls.DataList> control are bound to the control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListItemDataBound#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemDataBound/CS/datalistitemdataboundcs.aspx#1)]
[!code-aspx-vb[DataListItemDataBound#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemDataBound/VB/datalistitemdataboundvb.aspx#1)]
[!code-aspx-csharp[DataListItemDataBound2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemDataBound2/CS/datalistitemdatabound2cs.aspx#1)]
[!code-aspx-vb[DataListItemDataBound2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemDataBound2/VB/datalistitemdatabound2vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.DataListItemEventHandler" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnItemDataBound(System.Web.UI.WebControls.DataListItemEventArgs)" />
<related type="Article" href="https://msdn.microsoft.com/library/73bf8638-c4ec-4069-b0bb-a1dc79b92e32">How to: Consume Events in a Web Forms Application</related>
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="Items">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.WebControls.DataListItemCollection Items { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.DataListItemCollection Items" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.Items" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property Items As DataListItemCollection" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::WebControls::DataListItemCollection ^ Items { System::Web::UI::WebControls::DataListItemCollection ^ get(); };" />
<MemberSignature Language="F#" Value="member this.Items : System.Web.UI.WebControls.DataListItemCollection" Usage="System.Web.UI.WebControls.DataList.Items" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.Browsable(false)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.DataListItemCollection</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a collection of <see cref="T:System.Web.UI.WebControls.DataListItem" /> objects representing the individual items within the control.</summary>
<value>A <see cref="T:System.Web.UI.WebControls.DataListItemCollection" /> that contains a collection of <see cref="T:System.Web.UI.WebControls.DataListItem" /> objects representing the individual items within the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.Items%2A> collection to programmatically control the items in the <xref:System.Web.UI.WebControls.DataList> control. The <xref:System.Web.UI.WebControls.DataList.Items%2A> collection does not provide any methods to add or remove items to the collection. However, you can control the contents of an item by providing a handler for the <xref:System.Web.UI.WebControls.DataList.ItemCreated> event.
> [!NOTE]
> Only items bound to the data source are contained in the <xref:System.Web.UI.WebControls.DataList.Items%2A> collection. The header, footer, and separator are not included in the collection.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.Items%2A> collection to display the items in the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[Classic DataList.Items Example#1](~/samples/snippets/csharp/VS_Snippets_WebNet/Classic DataList.Items Example/CS/sourcecs.aspx#1)]
[!code-aspx-vb[Classic DataList.Items Example#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/Classic DataList.Items Example/VB/sourcevb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.DataListItem" />
<altmember cref="E:System.Web.UI.WebControls.DataList.ItemCreated" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnItemCreated(System.Web.UI.WebControls.DataListItemEventArgs)" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="ItemStyle">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.WebControls.TableItemStyle ItemStyle { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.TableItemStyle ItemStyle" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.ItemStyle" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property ItemStyle As TableItemStyle" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::WebControls::TableItemStyle ^ ItemStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };" />
<MemberSignature Language="F#" Value="member this.ItemStyle : System.Web.UI.WebControls.TableItemStyle" Usage="System.Web.UI.WebControls.DataList.ItemStyle" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(null)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.NotifyParentProperty(true)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.TableItemStyle</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the style properties for the items in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<value>A <see cref="T:System.Web.UI.WebControls.TableItemStyle" /> object that contains the style properties for the items in the <see cref="T:System.Web.UI.WebControls.DataList" /> control. The default value is an empty <see cref="T:System.Web.UI.WebControls.TableItemStyle" /> object.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use this property to provide a custom style for the items of the <xref:System.Web.UI.WebControls.DataList> control. Common style attributes that can be adjusted include foreground color, background color, font, and content alignment within the cell. Providing a different style enhances the appearance of the <xref:System.Web.UI.WebControls.DataList> control.
Item style properties in the <xref:System.Web.UI.WebControls.DataList> control are inherited from one item style property to another through a hierarchy. Item style properties set lower in the hierarchy are inherited by item style properties higher in the hierarchy. For example, if you specify a red font for the <xref:System.Web.UI.WebControls.DataList.ItemStyle%2A> property, all other item style properties in the <xref:System.Web.UI.WebControls.DataList> control will also have a red font. This allows you to provide a common appearance for the control by setting a single item style property. You can override the inherited style settings for an item style property that is higher in the hierarchy by setting its style properties. For example, you can specify a blue font for the <xref:System.Web.UI.WebControls.DataList.AlternatingItemStyle%2A> property, overriding the red font specified in the <xref:System.Web.UI.WebControls.DataList.ItemStyle%2A> property. The following table lists the hierarchy order from highest to lowest.
|Precedence|Style Property|
|----------------|--------------------|
|1|<xref:System.Web.UI.WebControls.DataList.EditItemStyle%2A>|
|2|<xref:System.Web.UI.WebControls.DataList.SelectedItemStyle%2A>|
|3|<xref:System.Web.UI.WebControls.DataList.AlternatingItemStyle%2A>|
|4|<xref:System.Web.UI.WebControls.DataList.ItemStyle%2A>|
|5|<xref:System.Web.UI.WebControls.WebControl.ControlStyle%2A>|
To specify a custom style for the items of the <xref:System.Web.UI.WebControls.DataList> control, place the `<ItemStyle>` tags between the opening and closing tags of the <xref:System.Web.UI.WebControls.DataList> control. You can then list the style attributes within the opening `<ItemStyle>` tag.
You can also use the <xref:System.Web.UI.WebControls.DataList.AlternatingItemStyle%2A> property to provide a different appearance for the alternating items in the <xref:System.Web.UI.WebControls.DataList> control.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.ItemStyle%2A> property to specify a different background color for the items in the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListItemStyle#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemStyle/CS/datalistitemstylecs.aspx#1)]
[!code-aspx-vb[DataListItemStyle#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemStyle/VB/datalistitemstylevb.aspx#1)]
]]></format>
</remarks>
<altmember cref="P:System.Web.UI.WebControls.DataList.ItemTemplate" />
<altmember cref="P:System.Web.UI.WebControls.DataList.AlternatingItemStyle" />
<altmember cref="T:System.Web.UI.WebControls.TableItemStyle" />
<altmember cref="T:System.Web.UI.WebControls.Style" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="ItemTemplate">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.ITemplate ItemTemplate { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.ITemplate ItemTemplate" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.ItemTemplate" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property ItemTemplate As ITemplate" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::ITemplate ^ ItemTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };" />
<MemberSignature Language="F#" Value="member this.ItemTemplate : System.Web.UI.ITemplate with get, set" Usage="System.Web.UI.WebControls.DataList.ItemTemplate" />
<MemberType>Property</MemberType>
<Implements>
<InterfaceMember>P:System.Web.UI.WebControls.IWizardSideBarListControl.ItemTemplate</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.Browsable(false)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(null)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.DataListItem))</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.ITemplate</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the template for the items in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<value>A <see cref="T:System.Web.UI.ITemplate" /> that contains the template for the items in the <see cref="T:System.Web.UI.WebControls.DataList" /> control. The default value is <see langword="null" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.ItemTemplate%2A> property to control the contents of the items in the <xref:System.Web.UI.WebControls.DataList> control. The appearance of the items in the <xref:System.Web.UI.WebControls.DataList> control is controlled by the <xref:System.Web.UI.WebControls.DataList.ItemStyle%2A> property.
To specify a template for the items of the <xref:System.Web.UI.WebControls.DataList> control, place the `<ItemTemplate>` tags between the opening and closing tags of the <xref:System.Web.UI.WebControls.DataList> control. You can then list the contents of the template between the opening and closing `<ItemTemplate>` tags.
You can optionally use the <xref:System.Web.UI.WebControls.DataList.AlternatingItemTemplate%2A> property to provide a different appearance for the alternating items in the <xref:System.Web.UI.WebControls.DataList> control.
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.ItemTemplate%2A> property to control the contents of the items in the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListLayout#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListLayout/CS/datalistlayoutcs.aspx#1)]
[!code-aspx-vb[DataListLayout#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListLayout/VB/datalistlayoutvb.aspx#1)]
]]></format>
</remarks>
<altmember cref="P:System.Web.UI.WebControls.DataList.AlternatingItemTemplate" />
<altmember cref="P:System.Web.UI.WebControls.DataList.ItemStyle" />
<altmember cref="T:System.Web.UI.ITemplate" />
<related type="Article" href="https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8">Securing Standard Controls</related>
<related type="Article" href="https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b">How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings</related>
<related type="Article" href="https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461">Introduction to Validating User Input in ASP.NET Web Pages</related>
</Docs>
</Member>
<Member MemberName="LoadViewState">
<MemberSignature Language="C#" Value="protected override void LoadViewState (object savedState);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void LoadViewState(object savedState) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.LoadViewState(System.Object)" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Sub LoadViewState (savedState As Object)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override void LoadViewState(System::Object ^ savedState);" />
<MemberSignature Language="F#" Value="override this.LoadViewState : obj -&gt; unit" Usage="dataList.LoadViewState savedState" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="savedState" Type="System.Object" />
</Parameters>
<Docs>
<param name="savedState">An object that represents the state of the <see cref="T:System.Web.UI.WebControls.DataList" />.</param>
<summary>Loads the previously saved view state of the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method is used primarily by the .NET Framework infrastructure and is not intended to be used directly from your code. However, control developers can override this method to specify how a custom server control restores its view state. For more information, see [ASP.NET State Management Overview](https://msdn.microsoft.com/library/0218d965-5d30-445b-b6a6-8870e70e63ce(v=vs.100)).
The <xref:System.Web.UI.WebControls.DataList.LoadViewState%2A> method restores view-state information for the <xref:System.Web.UI.WebControls.DataList> control from a previous page request that was saved by the <xref:System.Web.UI.WebControls.DataList.SaveViewState%2A> method.
]]></format>
</remarks>
<altmember cref="M:System.Web.UI.WebControls.DataList.SaveViewState" />
<altmember cref="M:System.Web.UI.WebControls.DataList.TrackViewState" />
<related type="Article" href="https://msdn.microsoft.com/library/9e98c7de-a888-48df-b14e-02ec8bef7681">Control State vs. View State Sample</related>
</Docs>
</Member>
<Member MemberName="OnBubbleEvent">
<MemberSignature Language="C#" Value="protected override bool OnBubbleEvent (object source, EventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance bool OnBubbleEvent(object source, class System.EventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.OnBubbleEvent(System.Object,System.EventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Function OnBubbleEvent (source As Object, e As EventArgs) As Boolean" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override bool OnBubbleEvent(System::Object ^ source, EventArgs ^ e);" />
<MemberSignature Language="F#" Value="override this.OnBubbleEvent : obj * EventArgs -&gt; bool" Usage="dataList.OnBubbleEvent (source, e)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="source" Type="System.Object" />
<Parameter Name="e" Type="System.EventArgs" />
</Parameters>
<Docs>
<param name="source">The source of the event.</param>
<param name="e">The event data.</param>
<summary>Determines whether the event for the server control is passed up the page's UI server control hierarchy.</summary>
<returns>
<see langword="true" /> if the event has been canceled; otherwise, <see langword="false" />. The default is <see langword="false" />.</returns>
<remarks>To be added.</remarks>
<altmember cref="M:System.Web.UI.Control.OnBubbleEvent(System.Object,System.EventArgs)" />
</Docs>
</Member>
<Member MemberName="OnCancelCommand">
<MemberSignature Language="C#" Value="protected virtual void OnCancelCommand (System.Web.UI.WebControls.DataListCommandEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void OnCancelCommand(class System.Web.UI.WebControls.DataListCommandEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.OnCancelCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub OnCancelCommand (e As DataListCommandEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual void OnCancelCommand(System::Web::UI::WebControls::DataListCommandEventArgs ^ e);" />
<MemberSignature Language="F#" Value="abstract member OnCancelCommand : System.Web.UI.WebControls.DataListCommandEventArgs -&gt; unit&#xA;override this.OnCancelCommand : System.Web.UI.WebControls.DataListCommandEventArgs -&gt; unit" Usage="dataList.OnCancelCommand e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Web.UI.WebControls.DataListCommandEventArgs" />
</Parameters>
<Docs>
<param name="e">A <see cref="T:System.Web.UI.WebControls.DataListCommandEventArgs" /> that contains event data.</param>
<summary>Raises the <see cref="E:System.Web.UI.WebControls.DataList.CancelCommand" /> event. This allows you to provide a custom handler for the event.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.OnCancelCommand%2A> method to provide a custom handler for the <xref:System.Web.UI.WebControls.DataList.CancelCommand> event.
The <xref:System.Web.UI.WebControls.DataList.CancelCommand> event is raised when the `Cancel` button is clicked for an item in the <xref:System.Web.UI.WebControls.DataList> control.
A typical handler for the <xref:System.Web.UI.WebControls.DataList.CancelCommand> event sets the <xref:System.Web.UI.WebControls.DataList.EditItemIndex%2A> property to `-1` (to deselect the item) and then rebinds the data to the <xref:System.Web.UI.WebControls.DataList> control.
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
Raising an event invokes the event handler through a delegate. For more information, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
The <xref:System.Web.UI.WebControls.DataList.OnCancelCommand%2A> method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.CancelCommand> event. It cancels any edits made to an item in the <xref:System.Web.UI.WebControls.DataList> control when the `Cancel` button is clicked.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListEdit#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit/CS/datalisteditcs.aspx#1)]
[!code-aspx-vb[DataListEdit#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit/VB/datalisteditvb.aspx#1)]
[!code-aspx-csharp[DataListEdit2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit2/CS/datalistedit2cs.aspx#1)]
[!code-aspx-vb[DataListEdit2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit2/VB/datalistedit2vb.aspx#1)]
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>When overriding <see cref="M:System.Web.UI.WebControls.DataList.OnCancelCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" /> in a derived class, be sure to call the base class's <see cref="M:System.Web.UI.WebControls.DataList.OnCancelCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" /> method so that registered delegates receive the event.</para>
</block>
<altmember cref="E:System.Web.UI.WebControls.DataList.CancelCommand" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnDeleteCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnEditCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnUpdateCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="T:System.Web.UI.WebControls.DataListCommandEventArgs" />
<related type="Article" href="https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8">Securing Standard Controls</related>
<related type="Article" href="https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b">How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings</related>
<related type="Article" href="https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461">Introduction to Validating User Input in ASP.NET Web Pages</related>
</Docs>
</Member>
<Member MemberName="OnDeleteCommand">
<MemberSignature Language="C#" Value="protected virtual void OnDeleteCommand (System.Web.UI.WebControls.DataListCommandEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void OnDeleteCommand(class System.Web.UI.WebControls.DataListCommandEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.OnDeleteCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub OnDeleteCommand (e As DataListCommandEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual void OnDeleteCommand(System::Web::UI::WebControls::DataListCommandEventArgs ^ e);" />
<MemberSignature Language="F#" Value="abstract member OnDeleteCommand : System.Web.UI.WebControls.DataListCommandEventArgs -&gt; unit&#xA;override this.OnDeleteCommand : System.Web.UI.WebControls.DataListCommandEventArgs -&gt; unit" Usage="dataList.OnDeleteCommand e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Web.UI.WebControls.DataListCommandEventArgs" />
</Parameters>
<Docs>
<param name="e">A <see cref="T:System.Web.UI.WebControls.DataListCommandEventArgs" /> that contains event data.</param>
<summary>Raises the <see cref="E:System.Web.UI.WebControls.DataList.DeleteCommand" /> event. This allows you to provide a custom handler for the event.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.OnDeleteCommand%2A> method to provide a custom handler for the <xref:System.Web.UI.WebControls.DataList.DeleteCommand> event.
The <xref:System.Web.UI.WebControls.DataList.DeleteCommand> event is raised when the `Delete` button is clicked for an item in the <xref:System.Web.UI.WebControls.DataList> control.
A typical handler for the <xref:System.Web.UI.WebControls.DataList.DeleteCommand> event removes the selected item from the data source and then rebinds the data to the <xref:System.Web.UI.WebControls.DataList> control.
Raising an event invokes the event handler through a delegate. For more information, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
The <xref:System.Web.UI.WebControls.DataList.OnDeleteCommand%2A> method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.DeleteCommand> event. It deletes the selected item in the <xref:System.Web.UI.WebControls.DataList> control when the `Delete` button is clicked.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListEdit#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit/CS/datalisteditcs.aspx#1)]
[!code-aspx-vb[DataListEdit#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit/VB/datalisteditvb.aspx#1)]
[!code-aspx-csharp[DataListEdit2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit2/CS/datalistedit2cs.aspx#1)]
[!code-aspx-vb[DataListEdit2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit2/VB/datalistedit2vb.aspx#1)]
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>When overriding <see cref="M:System.Web.UI.WebControls.DataList.OnDeleteCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" /> in a derived class, be sure to call the base class's <see cref="M:System.Web.UI.WebControls.DataList.OnDeleteCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" /> method so that registered delegates receive the event.</para>
</block>
<altmember cref="E:System.Web.UI.WebControls.DataList.DeleteCommand" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnCancelCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnEditCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnUpdateCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="T:System.Web.UI.WebControls.DataListCommandEventArgs" />
</Docs>
</Member>
<Member MemberName="OnEditCommand">
<MemberSignature Language="C#" Value="protected virtual void OnEditCommand (System.Web.UI.WebControls.DataListCommandEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void OnEditCommand(class System.Web.UI.WebControls.DataListCommandEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.OnEditCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub OnEditCommand (e As DataListCommandEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual void OnEditCommand(System::Web::UI::WebControls::DataListCommandEventArgs ^ e);" />
<MemberSignature Language="F#" Value="abstract member OnEditCommand : System.Web.UI.WebControls.DataListCommandEventArgs -&gt; unit&#xA;override this.OnEditCommand : System.Web.UI.WebControls.DataListCommandEventArgs -&gt; unit" Usage="dataList.OnEditCommand e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Web.UI.WebControls.DataListCommandEventArgs" />
</Parameters>
<Docs>
<param name="e">A <see cref="T:System.Web.UI.WebControls.DataListCommandEventArgs" /> that contains event data.</param>
<summary>Raises the <see cref="E:System.Web.UI.WebControls.DataList.EditCommand" /> event. This allows you to provide a custom handler for the event.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.OnEditCommand%2A> method to provide a custom handler for the <xref:System.Web.UI.WebControls.DataList.EditCommand> event.
The <xref:System.Web.UI.WebControls.DataList.EditCommand> event is raised when the `Edit` button is clicked for an item in the <xref:System.Web.UI.WebControls.DataList> control.
A typical handler for the <xref:System.Web.UI.WebControls.DataList.EditCommand> event sets the <xref:System.Web.UI.WebControls.DataList.EditItemIndex%2A> property to the selected row and then rebinds the data to the <xref:System.Web.UI.WebControls.DataList> control.
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
Raising an event invokes the event handler through a delegate. For more information, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
The <xref:System.Web.UI.WebControls.DataList.OnEditCommand%2A> method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.EditCommand> event. It allows you to edit the selected item in the <xref:System.Web.UI.WebControls.DataList> control when the `Edit` button is clicked.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListEdit#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit/CS/datalisteditcs.aspx#1)]
[!code-aspx-vb[DataListEdit#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit/VB/datalisteditvb.aspx#1)]
[!code-aspx-csharp[DataListEdit2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit2/CS/datalistedit2cs.aspx#1)]
[!code-aspx-vb[DataListEdit2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit2/VB/datalistedit2vb.aspx#1)]
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>When overriding <see cref="M:System.Web.UI.WebControls.DataList.OnEditCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" /> in a derived class, be sure to call the base class's <see cref="M:System.Web.UI.WebControls.DataList.OnEditCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" /> method so that registered delegates receive the event.</para>
</block>
<altmember cref="E:System.Web.UI.WebControls.DataList.EditCommand" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnCancelCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnDeleteCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnUpdateCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="T:System.Web.UI.WebControls.DataListCommandEventArgs" />
<related type="Article" href="https://msdn.microsoft.com/library/73bf8638-c4ec-4069-b0bb-a1dc79b92e32">How to: Consume Events in a Web Forms Application</related>
</Docs>
</Member>
<Member MemberName="OnInit">
<MemberSignature Language="C#" Value="protected internal override void OnInit (EventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyorassemblyhidebysig virtual instance void OnInit(class System.EventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.OnInit(System.EventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Friend Overrides Sub OnInit (e As EventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected public:&#xA; override void OnInit(EventArgs ^ e);" />
<MemberSignature Language="F#" Value="override this.OnInit : EventArgs -&gt; unit" Usage="dataList.OnInit e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.EventArgs" Index="0" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8" />
</Parameters>
<Docs>
<param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
<summary>Raises the <see cref="E:System.Web.UI.Control.Init" /> event for the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.OnInit%2A> method notifies the <xref:System.Web.UI.WebControls.DataList> control to perform any initialization steps that are required to create and set up an instance.
]]></format>
</remarks>
<altmember cref="M:System.Web.UI.Control.OnInit(System.EventArgs)" />
</Docs>
</Member>
<Member MemberName="OnItemCommand">
<MemberSignature Language="C#" Value="protected virtual void OnItemCommand (System.Web.UI.WebControls.DataListCommandEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void OnItemCommand(class System.Web.UI.WebControls.DataListCommandEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.OnItemCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub OnItemCommand (e As DataListCommandEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual void OnItemCommand(System::Web::UI::WebControls::DataListCommandEventArgs ^ e);" />
<MemberSignature Language="F#" Value="abstract member OnItemCommand : System.Web.UI.WebControls.DataListCommandEventArgs -&gt; unit&#xA;override this.OnItemCommand : System.Web.UI.WebControls.DataListCommandEventArgs -&gt; unit" Usage="dataList.OnItemCommand e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Web.UI.WebControls.DataListCommandEventArgs" />
</Parameters>
<Docs>
<param name="e">A <see cref="T:System.Web.UI.WebControls.DataListCommandEventArgs" /> that contains event data.</param>
<summary>Raises the <see cref="E:System.Web.UI.WebControls.DataList.ItemCommand" /> event. This allows you to provide a custom handler for the event.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.OnItemCommand%2A> method to provide a custom handler for the <xref:System.Web.UI.WebControls.DataList.ItemCommand> event.
The <xref:System.Web.UI.WebControls.DataList.ItemCommand> event is raised when any button is clicked in the <xref:System.Web.UI.WebControls.DataList> control and is commonly used when you have a button control with a custom `CommandName` value, such as `Add`, in the <xref:System.Web.UI.WebControls.DataList> control.
Raising an event invokes the event handler through a delegate. For more information, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
The <xref:System.Web.UI.WebControls.DataList.OnItemCommand%2A> method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.ItemCommand> event to select an item from the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListItemCommand#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemCommand/CS/datalistitemcommandcs.aspx#1)]
[!code-aspx-vb[DataListItemCommand#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemCommand/VB/datalistitemcommandvb.aspx#1)]
[!code-aspx-csharp[DataListItemCommand2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemCommand2/CS/datalistitemcommand2cs.aspx#1)]
[!code-aspx-vb[DataListItemCommand2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemCommand2/VB/datalistitemcommand2vb.aspx#1)]
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>When overriding <see cref="M:System.Web.UI.WebControls.DataList.OnItemCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" /> in a derived class, be sure to call the base class's <see cref="M:System.Web.UI.WebControls.DataList.OnItemCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" /> method so that registered delegates receive the event.</para>
</block>
<altmember cref="E:System.Web.UI.WebControls.DataList.ItemCommand" />
<altmember cref="T:System.Web.UI.WebControls.DataListCommandEventArgs" />
<related type="Article" href="https://msdn.microsoft.com/library/73bf8638-c4ec-4069-b0bb-a1dc79b92e32">How to: Consume Events in a Web Forms Application</related>
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="OnItemCreated">
<MemberSignature Language="C#" Value="protected virtual void OnItemCreated (System.Web.UI.WebControls.DataListItemEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void OnItemCreated(class System.Web.UI.WebControls.DataListItemEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.OnItemCreated(System.Web.UI.WebControls.DataListItemEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub OnItemCreated (e As DataListItemEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual void OnItemCreated(System::Web::UI::WebControls::DataListItemEventArgs ^ e);" />
<MemberSignature Language="F#" Value="abstract member OnItemCreated : System.Web.UI.WebControls.DataListItemEventArgs -&gt; unit&#xA;override this.OnItemCreated : System.Web.UI.WebControls.DataListItemEventArgs -&gt; unit" Usage="dataList.OnItemCreated e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Web.UI.WebControls.DataListItemEventArgs" />
</Parameters>
<Docs>
<param name="e">A <see cref="T:System.Web.UI.WebControls.DataListItemEventArgs" /> that contains event data.</param>
<summary>Raises the <see cref="E:System.Web.UI.WebControls.DataList.ItemCreated" /> event. This allows you to provide a custom handler for the event.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.OnItemCreated%2A> method to provide a custom handler for the <xref:System.Web.UI.WebControls.DataList.ItemCreated> event.
The <xref:System.Web.UI.WebControls.DataList.ItemCreated> event is raised when an item in the <xref:System.Web.UI.WebControls.DataList> control is created, both during round-trips and at the time data is bound to the control.
The <xref:System.Web.UI.WebControls.DataList.ItemCreated> event is commonly used to control the content and appearance of a row in the <xref:System.Web.UI.WebControls.DataList> control.
Raising an event invokes the event handler through a delegate. For more information, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
The <xref:System.Web.UI.WebControls.DataList.OnItemCreated%2A> method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.ItemCreated> event to display the order in which items in the <xref:System.Web.UI.WebControls.DataList> control are created.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListItemCreated#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemCreated/CS/datalistitemcreatedcs.aspx#1)]
[!code-aspx-vb[DataListItemCreated#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemCreated/VB/datalistitemcreatedvb.aspx#1)]
[!code-aspx-csharp[DataListItemCreated2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemCreated2/CS/datalistitemcreated2cs.aspx#1)]
[!code-aspx-vb[DataListItemCreated2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemCreated2/VB/datalistitemcreated2vb.aspx#1)]
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>When overriding <see cref="M:System.Web.UI.WebControls.DataList.OnItemCreated(System.Web.UI.WebControls.DataListItemEventArgs)" /> in a derived class, be sure to call the base class's <see cref="M:System.Web.UI.WebControls.DataList.OnItemCreated(System.Web.UI.WebControls.DataListItemEventArgs)" /> method so that registered delegates receive the event.</para>
</block>
<altmember cref="E:System.Web.UI.WebControls.DataList.ItemCreated" />
<altmember cref="T:System.Web.UI.WebControls.DataListItemEventArgs" />
<related type="Article" href="https://msdn.microsoft.com/library/73bf8638-c4ec-4069-b0bb-a1dc79b92e32">How to: Consume Events in a Web Forms Application</related>
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="OnItemDataBound">
<MemberSignature Language="C#" Value="protected virtual void OnItemDataBound (System.Web.UI.WebControls.DataListItemEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void OnItemDataBound(class System.Web.UI.WebControls.DataListItemEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.OnItemDataBound(System.Web.UI.WebControls.DataListItemEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub OnItemDataBound (e As DataListItemEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual void OnItemDataBound(System::Web::UI::WebControls::DataListItemEventArgs ^ e);" />
<MemberSignature Language="F#" Value="abstract member OnItemDataBound : System.Web.UI.WebControls.DataListItemEventArgs -&gt; unit&#xA;override this.OnItemDataBound : System.Web.UI.WebControls.DataListItemEventArgs -&gt; unit" Usage="dataList.OnItemDataBound e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Web.UI.WebControls.DataListItemEventArgs" />
</Parameters>
<Docs>
<param name="e">A <see cref="T:System.Web.UI.WebControls.DataListItemEventArgs" /> that contains event data.</param>
<summary>Raises the <see cref="E:System.Web.UI.WebControls.DataList.ItemDataBound" /> event. This allows you to provide a custom handler for the event.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.OnItemDataBound%2A> method to provide a custom handler for the <xref:System.Web.UI.WebControls.DataList.ItemDataBound> event.
The <xref:System.Web.UI.WebControls.DataList.ItemDataBound> event is raised after an item is data bound to the <xref:System.Web.UI.WebControls.DataList> control. This event provides you with the last opportunity to access the data item before it is displayed on the client. After this event is raised, the data item is no longer available.
Raising an event invokes the event handler through a delegate. For more information, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
The <xref:System.Web.UI.WebControls.DataList.OnItemDataBound%2A> method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.ItemDataBound> event to display the order in which items in the <xref:System.Web.UI.WebControls.DataList> control are bound to the control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListItemDataBound#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemDataBound/CS/datalistitemdataboundcs.aspx#1)]
[!code-aspx-vb[DataListItemDataBound#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemDataBound/VB/datalistitemdataboundvb.aspx#1)]
[!code-aspx-csharp[DataListItemDataBound2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemDataBound2/CS/datalistitemdatabound2cs.aspx#1)]
[!code-aspx-vb[DataListItemDataBound2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemDataBound2/VB/datalistitemdatabound2vb.aspx#1)]
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>When overriding <see cref="M:System.Web.UI.WebControls.DataList.OnItemDataBound(System.Web.UI.WebControls.DataListItemEventArgs)" /> in a derived class, be sure to call the base class's <see cref="M:System.Web.UI.WebControls.DataList.OnItemDataBound(System.Web.UI.WebControls.DataListItemEventArgs)" /> method so that registered delegates receive the event.</para>
</block>
<altmember cref="E:System.Web.UI.WebControls.DataList.ItemDataBound" />
<altmember cref="T:System.Web.UI.WebControls.DataListItemEventArgs" />
<related type="Article" href="https://msdn.microsoft.com/library/73bf8638-c4ec-4069-b0bb-a1dc79b92e32">How to: Consume Events in a Web Forms Application</related>
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="OnUpdateCommand">
<MemberSignature Language="C#" Value="protected virtual void OnUpdateCommand (System.Web.UI.WebControls.DataListCommandEventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void OnUpdateCommand(class System.Web.UI.WebControls.DataListCommandEventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.OnUpdateCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub OnUpdateCommand (e As DataListCommandEventArgs)" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; virtual void OnUpdateCommand(System::Web::UI::WebControls::DataListCommandEventArgs ^ e);" />
<MemberSignature Language="F#" Value="abstract member OnUpdateCommand : System.Web.UI.WebControls.DataListCommandEventArgs -&gt; unit&#xA;override this.OnUpdateCommand : System.Web.UI.WebControls.DataListCommandEventArgs -&gt; unit" Usage="dataList.OnUpdateCommand e" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.Web.UI.WebControls.DataListCommandEventArgs" />
</Parameters>
<Docs>
<param name="e">A <see cref="T:System.Web.UI.WebControls.DataListItemEventArgs" /> that contains event data.</param>
<summary>Raises the <see cref="E:System.Web.UI.WebControls.DataList.UpdateCommand" /> event. This allows you to provide a custom handler for the event.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.OnUpdateCommand%2A> method to provide a custom handler for the <xref:System.Web.UI.WebControls.DataList.UpdateCommand> event.
The <xref:System.Web.UI.WebControls.DataList.UpdateCommand> event is raised when the `Update` button for an item is clicked.
A typical handler for the <xref:System.Web.UI.WebControls.DataList.UpdateCommand> event updates the data, sets the <xref:System.Web.UI.WebControls.DataList.EditItemIndex%2A> property to `-1` (to deselect the item), and then rebinds the data to the <xref:System.Web.UI.WebControls.DataList> control.
> [!CAUTION]
> This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see [Securing Standard Controls](https://msdn.microsoft.com/library/f3e7718f-63d0-44a3-bd5f-48cc2059c2a8), [How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings](https://msdn.microsoft.com/library/6f67973f-dda0-45a1-ba9d-e88532d7dc5b), and [Validating User Input in ASP.NET Web Pages](https://msdn.microsoft.com/library/4ad3dacb-89e0-4cee-89ac-40a3f2a85461).
Raising an event invokes the event handler through a delegate. For more information, see [How to: Consume Events in a Web Forms Application](~/docs/standard/events/how-to-consume-events-in-a-web-forms-application.md).
The <xref:System.Web.UI.WebControls.DataList.OnUpdateCommand%2A> method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
## Examples
The following code example demonstrates how to specify and code a handler for the <xref:System.Web.UI.WebControls.DataList.UpdateCommand> event. It allows you to update the selected item in the <xref:System.Web.UI.WebControls.DataList> control with the new values entered by the user when the `Update` button is clicked.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListEdit#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit/CS/datalisteditcs.aspx#1)]
[!code-aspx-vb[DataListEdit#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit/VB/datalisteditvb.aspx#1)]
[!code-aspx-csharp[DataListEdit2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListEdit2/CS/datalistedit2cs.aspx#1)]
[!code-aspx-vb[DataListEdit2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListEdit2/VB/datalistedit2vb.aspx#1)]
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>When overriding <see cref="M:System.Web.UI.WebControls.DataList.OnUpdateCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" /> in a derived class, be sure to call the base class's <see cref="M:System.Web.UI.WebControls.DataList.OnUpdateCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" /> method so that registered delegates receive the event.</para>
</block>
<altmember cref="E:System.Web.UI.WebControls.DataList.UpdateCommand" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnCancelCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnDeleteCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="M:System.Web.UI.WebControls.DataList.OnEditCommand(System.Web.UI.WebControls.DataListCommandEventArgs)" />
<altmember cref="T:System.Web.UI.WebControls.DataListCommandEventArgs" />
</Docs>
</Member>
<Member MemberName="PrepareControlHierarchy">
<MemberSignature Language="C#" Value="protected internal override void PrepareControlHierarchy ();" />
<MemberSignature Language="ILAsm" Value=".method familyorassemblyhidebysig virtual instance void PrepareControlHierarchy() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.PrepareControlHierarchy" />
<MemberSignature Language="VB.NET" Value="Protected Friend Overrides Sub PrepareControlHierarchy ()" />
<MemberSignature Language="C++ CLI" Value="protected public:&#xA; override void PrepareControlHierarchy();" />
<MemberSignature Language="F#" Value="override this.PrepareControlHierarchy : unit -&gt; unit" Usage="dataList.PrepareControlHierarchy " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Prepares the control hierarchy for rendering in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.PrepareControlHierarchy%2A> method is used primarily by control developers when deriving a custom control from the <xref:System.Web.UI.WebControls.DataList> control.
The <xref:System.Web.UI.WebControls.DataList.PrepareControlHierarchy%2A> prepares the control hierarchy and sets styles for contained <xref:System.Web.UI.WebControls.DataListItem> controls before the child controls are rendered.
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>Override the <see cref="M:System.Web.UI.WebControls.DataList.PrepareControlHierarchy" /> method to customize styles for controls contained in the <see cref="T:System.Web.UI.WebControls.DataList" /> before they are rendered.</para>
</block>
<altmember cref="M:System.Web.UI.WebControls.DataList.RenderContents(System.Web.UI.HtmlTextWriter)" />
</Docs>
</Member>
<Member MemberName="RenderContents">
<MemberSignature Language="C#" Value="protected internal override void RenderContents (System.Web.UI.HtmlTextWriter writer);" />
<MemberSignature Language="ILAsm" Value=".method familyorassemblyhidebysig virtual instance void RenderContents(class System.Web.UI.HtmlTextWriter writer) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.RenderContents(System.Web.UI.HtmlTextWriter)" />
<MemberSignature Language="VB.NET" Value="Protected Friend Overrides Sub RenderContents (writer As HtmlTextWriter)" />
<MemberSignature Language="C++ CLI" Value="protected public:&#xA; override void RenderContents(System::Web::UI::HtmlTextWriter ^ writer);" />
<MemberSignature Language="F#" Value="override this.RenderContents : System.Web.UI.HtmlTextWriter -&gt; unit" Usage="dataList.RenderContents writer" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="writer" Type="System.Web.UI.HtmlTextWriter" />
</Parameters>
<Docs>
<param name="writer">A <see cref="T:System.Web.UI.HtmlTextWriter" /> that represents the output stream to render HTML content on the client.</param>
<summary>Renders the list items in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.RenderContents%2A> method is used primarily by control developers, when deriving a custom control from the <xref:System.Web.UI.WebControls.DataList> control.
The <xref:System.Web.UI.WebControls.DataList.RenderContents%2A> method renders the inner content of the <xref:System.Web.UI.WebControls.DataList> control, including the contained <xref:System.Web.UI.WebControls.DataListItem> controls.
## Examples
The following code example demonstrates how to override the <xref:System.Web.UI.WebControls.DataList.RenderContents%2A> method in a custom server control so that some text precedes the <xref:System.Web.UI.WebControls.DataList> object.
[!code-aspx-csharp[CustomDataListRenderContents#1](~/samples/snippets/csharp/VS_Snippets_WebNet/CustomDataListRenderContents/CS/custom_datalist_rendercontentscs.aspx#1)]
[!code-aspx-vb[CustomDataListRenderContents#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/CustomDataListRenderContents/VB/custom_datalist_rendercontentsvb.aspx#1)]
[!code-csharp[CustomDataListRenderContents#2](~/samples/snippets/csharp/VS_Snippets_WebNet/CustomDataListRenderContents/CS/custom_datalist_rendercontents.cs#2)]
[!code-vb[CustomDataListRenderContents#2](~/samples/snippets/visualbasic/VS_Snippets_WebNet/CustomDataListRenderContents/VB/custom_datalist_rendercontents.vb#2)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="RepeatColumns">
<MemberSignature Language="C#" Value="public virtual int RepeatColumns { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 RepeatColumns" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.RepeatColumns" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property RepeatColumns As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property int RepeatColumns { int get(); void set(int value); };" />
<MemberSignature Language="F#" Value="member this.RepeatColumns : int with get, set" Usage="System.Web.UI.WebControls.DataList.RepeatColumns" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(0)</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-1.1">
<AttributeName>System.ComponentModel.Bindable(true)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the number of columns to display in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<value>The number of columns to display in the <see cref="T:System.Web.UI.WebControls.DataList" /> control. The default value is <see langword="0" />, which indicates that the items in the <see cref="T:System.Web.UI.WebControls.DataList" /> control are displayed in a single row or column, based on the value of the <see cref="P:System.Web.UI.WebControls.DataList.RepeatDirection" /> property.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use this property to specify the number of columns that display items in the <xref:System.Web.UI.WebControls.DataList> control. For example, if you set this property to `5`, the <xref:System.Web.UI.WebControls.DataList> control displays its items in five columns.
> [!NOTE]
> If this property is set to `0`, the <xref:System.Web.UI.WebControls.DataList> control displays its items in a single row or column, based on the value of the <xref:System.Web.UI.WebControls.DataList.RepeatDirection%2A> property. If the <xref:System.Web.UI.WebControls.DataList.RepeatDirection%2A> property is set to `RepeatDirection.Horizontal`, the items are displayed in a single row. If the <xref:System.Web.UI.WebControls.DataList.RepeatDirection%2A> property is set to `RepeatDirection.Vertical`, the items are displayed in a single column.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.RepeatColumns%2A> property to specify the number of columns to display in the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListLayout#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListLayout/CS/datalistlayoutcs.aspx#1)]
[!code-aspx-vb[DataListLayout#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListLayout/VB/datalistlayoutvb.aspx#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">The specified number of columns is a negative value.</exception>
<altmember cref="P:System.Web.UI.WebControls.DataList.RepeatDirection" />
<altmember cref="P:System.Web.UI.WebControls.DataList.RepeatLayout" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="RepeatDirection">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.WebControls.RepeatDirection RepeatDirection { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Web.UI.WebControls.RepeatDirection RepeatDirection" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.RepeatDirection" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property RepeatDirection As RepeatDirection" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::WebControls::RepeatDirection RepeatDirection { System::Web::UI::WebControls::RepeatDirection get(); void set(System::Web::UI::WebControls::RepeatDirection value); };" />
<MemberSignature Language="F#" Value="member this.RepeatDirection : System.Web.UI.WebControls.RepeatDirection with get, set" Usage="System.Web.UI.WebControls.DataList.RepeatDirection" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(Mono.Cecil.CustomAttributeArgument)</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-1.1">
<AttributeName>System.ComponentModel.Bindable(true)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.RepeatDirection</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets whether the <see cref="T:System.Web.UI.WebControls.DataList" /> control displays vertically or horizontally.</summary>
<value>One of the <see cref="T:System.Web.UI.WebControls.RepeatDirection" /> values. The default is <see langword="Vertical" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.RepeatDirection%2A> property to specify the display direction of the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The number of columns displayed is always determined by the <xref:System.Web.UI.WebControls.DataList.RepeatColumns%2A> property.
If this property is set to `RepeatDirection.Vertical`, the items in the list are displayed in columns loaded from top to bottom, then left to right, until all items are rendered. For example, if the <xref:System.Web.UI.WebControls.DataList.RepeatColumns%2A> property is set to `3`, the items in the <xref:System.Web.UI.WebControls.DataList> control are displayed in three columns, as in the following table.
||||
|-|-|-|
|1|4|7|
|2|5|8|
|3|6|9|
If this property is set to `RepeatDirection.Horizontal`, the items in the list are displayed in rows loaded from left to right, then top to bottom, until all items are rendered. For example, if the <xref:System.Web.UI.WebControls.DataList.RepeatColumns%2A> property is set to `3`, the items of the <xref:System.Web.UI.WebControls.DataList> control are displayed in rows of three items each, as in the following table.
||||
|-|-|-|
|1|2|3|
|4|5|6|
|7|8|9|
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.RepeatDirection%2A> property to specify the direction in which the <xref:System.Web.UI.WebControls.DataList> control is displayed.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListLayout#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListLayout/CS/datalistlayoutcs.aspx#1)]
[!code-aspx-vb[DataListLayout#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListLayout/VB/datalistlayoutvb.aspx#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">The specified value is not one of the <see cref="T:System.Web.UI.WebControls.RepeatDirection" /> values.</exception>
<altmember cref="T:System.Web.UI.WebControls.RepeatDirection" />
<altmember cref="P:System.Web.UI.WebControls.DataList.RepeatColumns" />
<altmember cref="P:System.Web.UI.WebControls.DataList.RepeatLayout" />
<related type="Article" href="https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417">ASP.NET Web Page Code Model</related>
</Docs>
</Member>
<Member MemberName="RepeatLayout">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.WebControls.RepeatLayout RepeatLayout { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Web.UI.WebControls.RepeatLayout RepeatLayout" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.RepeatLayout" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property RepeatLayout As RepeatLayout" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property System::Web::UI::WebControls::RepeatLayout RepeatLayout { System::Web::UI::WebControls::RepeatLayout get(); void set(System::Web::UI::WebControls::RepeatLayout value); };" />
<MemberSignature Language="F#" Value="member this.RepeatLayout : System.Web.UI.WebControls.RepeatLayout with get, set" Usage="System.Web.UI.WebControls.DataList.RepeatLayout" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(Mono.Cecil.CustomAttributeArgument)</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-1.1">
<AttributeName>System.ComponentModel.Bindable(true)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.RepeatLayout</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets whether the control is displayed in a table or flow layout.</summary>
<value>A value that specifies whether the control is displayed in a table or in flow layout.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.RepeatLayout%2A> property to specify whether the items in the <xref:System.Web.UI.WebControls.DataList> control are displayed in a table. The only <xref:System.Web.UI.WebControls.RepeatLayout> values that are supported by the <xref:System.Web.UI.WebControls.DataList> control are <xref:System.Web.UI.WebControls.RepeatLayout.Table> and <xref:System.Web.UI.WebControls.RepeatLayout.Flow>.
If this property is set to `RepeatLayout.Table`, the items in the list are displayed in a table. If this property is set to `RepeatLayout.Flow`, the items in the list are displayed without a table structure.
When the <xref:System.Web.UI.WebControls.DataList> control is displayed in a table, you can use the <xref:System.Web.UI.WebControls.DataList.GridLines%2A> property to specify a grid line style.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.RepeatLayout%2A> property to specify the layout style of the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListLayout#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListLayout/CS/datalistlayoutcs.aspx#1)]
[!code-aspx-vb[DataListLayout#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListLayout/VB/datalistlayoutvb.aspx#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">The specified value is not one of the supported <see cref="T:System.Web.UI.WebControls.RepeatLayout" /> values.</exception>
<altmember cref="T:System.Web.UI.WebControls.RepeatLayout" />
<altmember cref="P:System.Web.UI.WebControls.DataList.RepeatColumns" />
<altmember cref="P:System.Web.UI.WebControls.DataList.RepeatDirection" />
<altmember cref="P:System.Web.UI.WebControls.DataList.GridLines" />
</Docs>
</Member>
<Member MemberName="SaveViewState">
<MemberSignature Language="C#" Value="protected override object SaveViewState ();" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance object SaveViewState() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataList.SaveViewState" />
<MemberSignature Language="VB.NET" Value="Protected Overrides Function SaveViewState () As Object" />
<MemberSignature Language="C++ CLI" Value="protected:&#xA; override System::Object ^ SaveViewState();" />
<MemberSignature Language="F#" Value="override this.SaveViewState : unit -&gt; obj" Usage="dataList.SaveViewState " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Saves the changes to the control view state since the time the page was posted back to the server.</summary>
<returns>The object that contains the changes to the <see cref="T:System.Web.UI.WebControls.DataList" /> view state.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataList.SaveViewState%2A> method is used primarily by control developers.
View state is the accumulation of the values of a server control's properties. These values are automatically placed in the server control's <xref:System.Web.UI.Control.ViewState%2A> property, which is an instance of the <xref:System.Web.UI.StateBag> class. The <xref:System.Web.UI.Control.ViewState%2A> property's value is then persisted to a string object after the save-state stage of the server control's life cycle. For more information, see [ASP.NET Page Life Cycle Overview](https://msdn.microsoft.com/library/7949d756-1a79-464e-891f-904b1cfc7991).
When view state is saved, this string object is returned to the client as a variable that is stored in a hidden HTML input element. When you author custom server controls, you can improve efficiency by overriding the <xref:System.Web.UI.WebControls.DataList.SaveViewState%2A> method and modifying the <xref:System.Web.UI.Control.ViewState%2A> property for your server control. For more information, see [Developing Custom ASP.NET Server Controls](https://msdn.microsoft.com/library/fbe26c16-cff4-4089-b3dd-877411f0c0ef) and [ASP.NET State Management Overview](https://msdn.microsoft.com/library/0218d965-5d30-445b-b6a6-8870e70e63ce(v=vs.100)).
]]></format>
</remarks>
<altmember cref="M:System.Web.UI.WebControls.DataList.TrackViewState" />
<altmember cref="M:System.Web.UI.WebControls.DataList.LoadViewState(System.Object)" />
<related type="Article" href="https://msdn.microsoft.com/library/9e98c7de-a888-48df-b14e-02ec8bef7681">Control State vs. View State Sample</related>
</Docs>
</Member>
<Member MemberName="SelectCommandName">
<MemberSignature Language="C#" Value="public const string SelectCommandName;" />
<MemberSignature Language="ILAsm" Value=".field public static literal string SelectCommandName" />
<MemberSignature Language="DocId" Value="F:System.Web.UI.WebControls.DataList.SelectCommandName" />
<MemberSignature Language="VB.NET" Value="Public Const SelectCommandName As String " />
<MemberSignature Language="C++ CLI" Value="public: System::String ^ SelectCommandName;" />
<MemberSignature Language="F#" Value="val mutable SelectCommandName : string" Usage="System.Web.UI.WebControls.DataList.SelectCommandName" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Represents the <see langword="Select" /> command name. This field is read-only.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.SelectCommandName> field to represent the `Select` command name.
]]></format>
</remarks>
<altmember cref="F:System.Web.UI.WebControls.DataList.EditCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.DeleteCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.UpdateCommandName" />
<altmember cref="F:System.Web.UI.WebControls.DataList.CancelCommandName" />
</Docs>
</Member>
<Member MemberName="SelectedIndex">
<MemberSignature Language="C#" Value="public virtual int SelectedIndex { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 SelectedIndex" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.SelectedIndex" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property SelectedIndex As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual property int SelectedIndex { int get(); void set(int value); };" />
<MemberSignature Language="F#" Value="member this.SelectedIndex : int with get, set" Usage="System.Web.UI.WebControls.DataList.SelectedIndex" />
<MemberType>Property</MemberType>
<Implements>
<InterfaceMember>P:System.Web.UI.WebControls.IWizardSideBarListControl.SelectedIndex</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.Bindable(true)</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.ComponentModel.DefaultValue(-1)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the index of the selected item in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</summary>
<value>The index of the selected item in the <see cref="T:System.Web.UI.WebControls.DataList" /> control.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataList.SelectedIndex%2A> property to programmatically specify the selected item in the <xref:System.Web.UI.WebControls.DataList> control. You can also use this property to determine the index of the selected item.
> [!NOTE]
> The <xref:System.Web.UI.WebControls.DataList.SelectedIndex%2A> property is zero based.
To deselect an item, set the <xref:System.Web.UI.WebControls.DataList.SelectedIndex%2A> property to `-1`.
The <xref:System.Web.UI.WebControls.DataList.SelectedIndex%2A> property is stored in control state.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.DataList.SelectedIndex%2A> property to specify the selected item in the <xref:System.Web.UI.WebControls.DataList> control.
> [!NOTE]
> The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see [ASP.NET Web Forms Page Code Model](https://msdn.microsoft.com/library/81b13e7a-b95b-4285-906f-d2dd77411417).
[!code-aspx-csharp[DataListItemCommand#1](~/samples/snippets/csharp/VS_Snippets_WebNet/DataListItemCommand/CS/datalistitemcommandcs.aspx#1)]
[!code-aspx-vb[DataListItemCommand#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/DataListItemCommand/VB/datalistitemcommandvb.aspx#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">The specified value is less than <see langword="-1" />.</exception>
<altmember cref="P:System.Web.UI.WebControls.DataList.SelectedItem" />
<altmember cref="P:System.Web.UI.WebControls.DataList.SelectedItemStyle" />
<altmember cref="P:System.Web.UI.WebControls.DataList.SelectedItemTemplate" />
</Docs>
</Member>
<Member MemberName="SelectedItem">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.WebControls.DataListItem SelectedItem { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.DataListItem SelectedItem" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataList.SelectedItem" />
<MemberSignature Language="VB.NET" Value=