System.Web 1.0.5000.0 2.0.0.0 Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details. System.Web.UI.WebControls.BaseDataList System.Web.UI.INamingContainer System.ComponentModel.Designer("System.Web.UI.Design.WebControls.DataGridDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner") System.ComponentModel.Editor("System.Web.UI.Design.WebControls.DataGridComponentEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.ComponentModel.ComponentEditor))

In this topic:

Introduction

Accessibility

Declarative Syntax

Before you use the control, consider using the control instead. The control, which was introduced in the .NET Framework version 2.0, is the successor to the control.

## Introduction

Use the control to display the fields of a data source as columns in a table. Each row in the control represents a record in the data source. The control supports selection, editing, deleting, paging, and sorting.

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. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. For more information, see [<topic://cpconASPNETSyntaxForValidationControls>].

Different column types determine the behavior of the columns in the control. The following table lists the different column types that can be used.

Column Type

Description

Displays a column bound to a field in a data source. It displays each item in the field as text. This is the default column type of the control.

Displays a command button for each item in the column. This allows you to create a column of custom button controls, such as Add or Remove buttons.

Displays a column that contains editing commands for each item in the column.

Displays the contents of each item in the column as a hyperlink. The contents of the column can be bound to a field in a data source or static text.

Displays each item in the column following a specified template. This allows you to provide custom controls in the column.

By default, the property is set to true, which creates a object for each field in the data source. Each field is then rendered as a column in the control in the order that each field appears in the data source.

You can also manually control which columns appear in the control by setting the property to false and then listing the columns that you want to include between the opening and closing <Columns> tags. The columns specified are added to the collection in the order listed. This allows you to programmatically control the columns in the control.

The order that the columns are displayed in the control is controlled by the order that the columns appear in the collection. Although you can programmatically change the order of the columns by manipulating the collection, it is easier to list the columns in the desired display order.

Explicitly declared columns can be displayed in conjunction with automatically generated columns. When using both, explicitly declared columns will be rendered first, followed by the automatically generated columns.

Automatically generated columns are not added to the collection.

The appearance of the 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

Specifies the style for alternating items in the control.

Specifies the style for the item being edited in the control.

Specifies the style for the footer section in the control.

Specifies the style for the header section in the control.

Specifies the style for the items in the control.

Specifies the style for the page selection section of the control.

Specifies the style for the selected item in the 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

Shows or hides the footer section of the control.

Shows or hides the header section of the control.

You can control the appearance of the control by programmatically adding attributes to the <td> and <tr> tags rendered by the control on the browser. Attributes can be programmatically added by providing code in the event handler for the or event.

To add an attribute to the <td> tag, first get the object that represents the cell in the control you want to add the attribute to. The collection for the property of the object passed into the event handler can be used to get the desired object. You can then use the method of the collection for the object to add attributes to the <td> tag.

To add an attribute to the <tr> tag, first get the object that represents the row in the control you want to add the attribute to. The property of the object passed into the event handler can be used to get the desired object. You can then use the method of the collection for the object to add attributes to the <tr> tag.

## Accessibility

For information about how to configure this control so that it generates markup that conforms to accessibility standards, see Accessibility in Visual Studio 2010 and ASP.NET 4 and ASP.NET Controls and Accessibility.

## Declarative Syntax

`<asp:DataGrid AccessKey="string" AllowCustomPaging="True|False" AllowPaging="True|False" AllowSorting="True|False" AutoGenerateColumns="True|False" BackColor="color name|#dddddd" BackImageUrl="uri" 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" 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" OnPageIndexChanged="PageIndexChanged event handler" OnPreRender="PreRender event handler" OnSelectedIndexChanged="SelectedIndexChanged event handler" OnSortCommand="SortCommand event handler" OnUnload="Unload event handler" OnUpdateCommand="UpdateCommand event handler" PageSize="integer" 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 /> <Columns> <asp:BoundColumn DataField="string" DataFormatString="string" FooterText="string" HeaderImageUrl="uri" HeaderText="string" ReadOnly="True|False" SortExpression="string" Visible="True|False" > <FooterStyle /> <HeaderStyle /> <ItemStyle /> </asp:BoundColumn> <asp:ButtonColumn ButtonType="LinkButton|PushButton" CausesValidation="True|False" CommandName="string" DataTextField="string" DataTextFormatString="string" FooterText="string" HeaderImageUrl="uri" HeaderText="string" SortExpression="string" Text="string" ValidationGroup="string" Visible="True|False" > <FooterStyle /> <HeaderStyle /> <ItemStyle /> </asp:ButtonColumn> <asp:EditCommandColumn ButtonType="LinkButton|PushButton" CancelText="string" CausesValidation="True|False" EditText="string" FooterText="string" HeaderImageUrl="uri" HeaderText="string" SortExpression="string" UpdateText="string" ValidationGroup="string" Visible="True|False" > <FooterStyle /> <HeaderStyle /> <ItemStyle /> </asp:EditCommandColumn> <asp:HyperLinkColumn DataNavigateUrlField="string" DataNavigateUrlFormatString="string" DataTextField="string" DataTextFormatString="string" FooterText="string" HeaderImageUrl="uri" HeaderText="string" NavigateUrl="uri" SortExpression="string" Target="string|_blank|_parent|_search|_self|_top" Text="string" Visible="True|False" > <FooterStyle /> <HeaderStyle /> <ItemStyle /> </asp:HyperLinkColumn> <asp:TemplateColumn FooterText="string" HeaderImageUrl="uri" HeaderText="string" SortExpression="string" Visible="True|False" > <FooterStyle /> <HeaderStyle /> <ItemStyle /> <EditItemTemplate> <!-- child controls --> </EditItemTemplate> <FooterTemplate> <!-- child controls --> </FooterTemplate> <HeaderTemplate> <!-- child controls --> </HeaderTemplate> <ItemTemplate> <!-- child controls --> </ItemTemplate> </asp:TemplateColumn> </Columns> <EditItemStyle /> <FooterStyle /> <HeaderStyle /> <ItemStyle /> <PagerStyle BackColor="color name|#dddddd" BorderColor="color name|#dddddd" BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double| Groove|Ridge|Inset|Outset" BorderWidth="size" CssClass="string" 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" Height="size" HorizontalAlign="NotSet|Left|Center|Right|Justify" Mode="NextPrev|NumericPages" NextPageText="string" OnDisposed="Disposed event handler" PageButtonCount="integer" Position="Bottom|Top|TopAndBottom" PrevPageText="string" VerticalAlign="NotSet|Top|Middle|Bottom" Visible="True|False" Width="size" Wrap="True|False" /> <SelectedItemStyle /> </asp:DataGrid>`

A data bound list control that displays the items from data source in a table. The control allows you to select, sort, and edit these items.

- Constructor

  Use this constructor to create and initialize a new instance of the class.

  Initializes a new instance of the class.

  1.0.5000.0
  2.0.0.0
- Property
  System.Boolean To be added: an object of type 'bool'

  Paging allows you to display the contents of the control in page segments. The number of items on a page is determined by the property. If no value is specified for the property, the will display 10 items on a page.

  Normally, a data source that contains every row in the control is loaded every time the control moves to a different page. This can consume a lot of resources when the data source is very large. Custom paging allows you to load just the segment of data needed to display a single page.

  To enable custom paging, set both the and properties to true. Next, provide code to handle the event.

  The typical logic for the event handler is to first set the property to the index of the page you want to display.

  The event handler receives a object as a parameter. You can use the property of this parameter to determine the index of the page selected by the user from the page selection elements of the control.

  Next, create a data source that contains the data to display on a single page and then use the method to bind the data to the control.

  Because only a segment of the data is loaded, you must set the property to the total number of items in the control. This allows the control to determine the total number of pages needed to display every item in the control. This property is normally programmatically set once the total number of items in the control is determined.

  When paging is enabled with the property is set to false, the control assumes that the data source contains all the items to be displayed. The control calculates the indexes of the items on the displayed page based on the page index, specified by the property, and the number of items on a page, specified by the property.

  When the property is set to true, the control assumes that the data source only contains the items as determined by the property. All items up to the number of items specified by the property are displayed.

  Gets or sets a value that indicates whether custom paging is enabled.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DefaultValue(false)
- Property
  System.Boolean To be added: an object of type 'bool'

  Paging allows you to display the contents of the control in page segments. The number of items on a page is determined by the property. If no value is specified for the property, the control will display 10 items on a page.

  By default, paging is disabled. To enable paging, set this property to true and provide code to handle the event.

  The typical logic for the event is to set the property to the index of the page you want to display and then use the method to bind the data to the control.

  The event handler receives a object as a parameter. You can use the property of this parameter to determine the index of the page selected by the user from the page selection elements of the control.

  With standard paging, the control assumes that the data source contains all the items to be displayed. The control calculates the indexes of the items on the displayed page based on the page index, specified by the property, and the number of items of items on a page, specified by the property.

  Normally, a data source that contains all items to be displayed is loaded every time the control is paged. This can consume a lot of resources when the data source is very large. Custom paging allows you to load just the segment of data needed to display a single page. For additional information on custom paging, see the property.

  Gets or sets a value that indicates whether paging is enabled.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DefaultValue(false)
- Property
  System.Boolean To be added: an object of type 'bool'

  When sorting is enabled, controls are rendered in the heading section of each column where the property is set. These controls allow you to sort the control by the selected column. The only exception is when you use a column type with the property set. In this case, you must provide a control in the of the column.

  The event is raised when one of the controls is clicked. It is up to you to provide code for the event handler. The typical logic for the handler is to sort the list, and then rebind the data to the control.

  Gets or sets a value that indicates whether sorting is enabled.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DefaultValue(false)
- Property
  System.Web.UI.WebControls.TableItemStyle To be added: an object of type 'TableItemStyle'

  Use the property to provide a custom style for the alternating items in the control. Common style attributes that can be adjusted include forecolor, backcolor, font, and content alignment within the cell. Providing a different style enhances the appearance of the control.

  Item style properties in the 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 property, all other item style properties in the 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 property, overriding the red font specified in the property. The following table lists the hierarchy order from highest to lowest.

  Precedence

  Style Property

  1

  2

  3

  4

  5

  To specify a custom style for the alternating items, place the <AlternatingItemStyle> tags between the opening and closing tags of the control. You can then list the style attributes within the opening <AlternatingItemStyle> tag.

  Gets the style properties for alternating items in the control.

  1.0.5000.0
  2.0.0.0
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.ComponentModel.NotifyParentProperty(true)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
- Property
  System.Boolean To be added: an object of type 'bool'

  Use this property to automatically create a object for each field in the data source. Each field is then rendered as a column in the control in the order that the fields appear in the data source.

  Not all data types can be bound to the control. If a field contains an unsupported data type, a column is not created for that field. If the data source only contains one column with an unsupported data type, an exception is thrown. The following table shows the data types that can be bound to the control.

  Data Type

  Description

  Primitives

  A primitive data type, such as , , , and so on. For a complete list, see .

  String

  A object.

  DateTime

  A object.

  Decimal

  A object.

  Explicitly declared columns may be used in conjunction with auto-generated columns. When using both, explicitly declared columns will be rendered first, followed by the auto-generated columns. Auto-generated columns are not added to the collection.

  Gets or sets a value that indicates whether objects are automatically created and displayed in the control for each field in the data source.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DefaultValue(true)
- Property
  System.String To be added: an object of type 'string'

  Use the property to specify an image to display in the background of the control.

  If the specified image is smaller than the control, the image will tile to fill in the background of the control.

  Gets or sets the URL of an image to display in the background of the control.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))
  System.ComponentModel.DefaultValue("")
  System.Web.UI.UrlProperty
- Event
  System.Web.UI.WebControls.DataGridCommandEventHandler

  The event is raised when the Cancel button is clicked for an item in the control.

  A typical handler for the event sets the property to -1 (to deselect the item) and then rebinds the data to the control.

  Text is not HTML encoded before it is displayed in the 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 [<topic://cpconEventsOverview>].

  Occurs when the Cancel button is clicked for an item in the control.

  1.0.5000.0
  2.0.0.0
- Field
  System.String

  Use the field to represent the Cancel command name.

  Represents the Cancel command name. This field is read-only.

  1.0.5000.0
  2.0.0.0
- Property
  System.Web.UI.WebControls.DataGridColumnCollection To be added: an object of type 'DataGridColumnCollection'

  Use this property to programmatically control the collection of columns in the control. The collection contains explicitly declared columns that get rendered in the control.

  Explicitly declared columns may be used in conjunction with automatically generated columns. When using both, explicitly declared columns will be rendered first, followed by the automatically generated columns. Automatically generated columns are not added to the collection.

  The order that the columns are displayed in the control is controlled by the order that the columns appear in the collection.

  The following table shows the different column classes that derive from the class and can be used in the collection.

  Column type

  Description

  Displays a column bound to a field in a data source. It displays each item in the field as text. This is the default column type of the control.

  Displays a command button for each item in the column. This allows you to create a column of custom button controls, such as the Add or Remove button.

  Displays a column that contains editing commands for each item in the column.

  Displays the contents of each item in the column as a hyperlink. The contents of the column can be bound to a field in a data source or static text.

  Displays each item in the column following a specified template. This allows you to provide custom controls in the column.

  Although you can programmatically add columns to the collection, it is easier to list the columns statically and then use the property to show or hide the column.

  Gets a collection of objects that represent the columns of the control.

  1.0.5000.0
  2.0.0.0
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.ComponentModel.MergableProperty(false)
  System.ComponentModel.Editor("System.Web.UI.Design.WebControls.DataGridColumnCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))
  System.ComponentModel.DefaultValue(null)
- Method
  System.Collections.ArrayList `` `` To be added

  Creates the set of columns to be used to build up the control hierarchy. When is true, the columns are created to match the data source and are appended to the set of columns defined in the collection.

  An containing the effective set of columns in the right order.

  The data source being used to create the control hierarchy Whether to use the data source to generate columns automatically or to use saved state. 1.0.5000.0 2.0.0.0
- Method
  System.Void ``

  This implementation assumes that all the children in the controls collection have already been cleared.

  Creates the control hierarchy that is used to render the .

  Whether to use the data source to generate columns automatically or to use saved state. 1.0.5000.0 2.0.0.0
- Method
  System.Web.UI.WebControls.Style To be added

  Creates new control style.

  A the represents the new style.

  1.0.5000.0
  2.0.0.0
- Method
  System.Web.UI.WebControls.DataGridItem `` `` ``

  The is a helper method used by the class to create its objects.

  This method is primarily used by control developers.

  Creates a object.

  A object.

  The index for the object. The index of the data item from the data source. One of the values. 1.0.5000.0 2.0.0.0
- Property
  System.Int32 To be added: an object of type 'int'

  Use this property to determine the currently displayed page in the control when paging is enabled. This property is also used to programmatically control which page is displayed.

  You can also hide the built in paging controls and create custom controls. To display a specific page, set this property to the page index you want to display and then rebind the data to the control.

  Gets or sets the index of the currently displayed page.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.ComponentModel.Browsable(false)
- Event
  System.Web.UI.WebControls.DataGridCommandEventHandler

  The event is raised when the Delete button is clicked for an item in the control.

  A typical handler for the event removes the selected item from the data source and then rebinds the data to the control.

  For more information about handling events, see [<topic://cpconEventsOverview>].

  Occurs when the Delete button is clicked for an item in the control.

  1.0.5000.0
  2.0.0.0
- Field
  System.String

  Use the field to represent the Delete command name.

  Represents the Delete command name. This field is read-only.

  1.0.5000.0
  2.0.0.0
- Event
  System.Web.UI.WebControls.DataGridCommandEventHandler

  The event is raised when the Edit button is clicked for an item in the control.

  A typical handler for the event sets the property to the selected row and then rebinds the data to the control.

  Text is not HTML encoded before it is displayed in the 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 [<topic://cpconEventsOverview>].

  Occurs when the Edit button is clicked for an item in the control.

  1.0.5000.0
  2.0.0.0
- Field
  System.String

  Use the field to represent the Edit command name.

  Represents the Edit command name. This field is read-only.

  1.0.5000.0
  2.0.0.0
- Property
  System.Int32 To be added: an object of type 'int'

  Use the property when the control contains an to determine the index of the item selected in the control to edit.

  This property is also used to programmatically control which item is being edited. Setting this property to an index of an item in the control will enable editing controls for that item in the .

  The property is zero based.

  To cancel editing, programmatically set this property to -1.

  Text is not HTML encoded before it is displayed in the 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.

  Gets or sets the index of an item in the control to edit.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DefaultValue(-1)
- Property
  System.Web.UI.WebControls.TableItemStyle To be added: an object of type 'TableItemStyle'

  Use the property to provide a custom style for the item selected for editing in the control. Common style attributes that can be adjusted include forecolor, backcolor, font, and content alignment within the cell. Providing a different style enhances the appearance of the control.

  Item style properties in the 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 property, all other item style properties in the 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 property, overriding the red font specified in the property. The following table lists the hierarchy order from highest to lowest.

  Precedence

  Style Property

  1

  2

  3

  4

  5

  To specify a custom style for the item selected for editing, place the <EditItemStyle> tags between the opening and closing tags of the control. You can then list the style attributes within the opening <EditItemStyle> tag.

  Gets the style properties of the item selected for editing in the control.

  1.0.5000.0
  2.0.0.0
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.ComponentModel.NotifyParentProperty(true)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
- Property
  System.Web.UI.WebControls.TableItemStyle To be added: an object of type 'TableItemStyle'

  Use this property to provide a custom style for the footer of the control. Common style attributes that can be adjusted include forecolor, backcolor, font, and content alignment within the cell. Providing a different style enhances the appearance of the control.

  The property of the control inherits the style settings of the property. For example, if you specify a red font for the property, the 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 property. For example, you can specify a blue font for the property, overriding the red font specified in the property.

  To specify a custom style for the footer section, place the <FooterStyle> tags between the opening and closing tags of the control. You can then list the style attributes within the opening <FooterStyle> tag.

  The property must be set to true for this property to be visible.

  Gets the style properties of the footer section in the control.

  1.0.5000.0
  2.0.0.0
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.ComponentModel.NotifyParentProperty(true)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
  System.ComponentModel.DefaultValue(null)
- Property
  System.Web.UI.WebControls.TableItemStyle To be added: an object of type 'TableItemStyle'

  Use this property to provide a custom style for the heading section of the control. Common style attributes that can be adjusted include forecolor, backcolor, font, and content alignment within the cell. Providing a different style enhances the appearance of the control.

  The property of the control inherits the style settings of the property. For example, if you specify a red font for the property, the 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 property. For example, you can specify a blue font for the property, overriding the red font specified in the property.

  To specify a custom style for the heading section, place the <HeaderStyle> tags between the opening and closing tags of the control. You can then list the style attributes within the opening <HeaderStyle> tag.

  The property must be set to true for this property to be visible.

  Gets the style properties of the heading section in the control.

  1.0.5000.0
  2.0.0.0
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.ComponentModel.NotifyParentProperty(true)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
  System.ComponentModel.DefaultValue(null)
- Method
  System.Void `` ``

  The method is a helper method used by the class to initialize the specified object.

  This method is primarily used by control developers.

  Initializes the specified object.

  The to initialize. An array of objects that contains the columns in this control. 1.0.5000.0 2.0.0.0
- Method
  System.Void `` `` ``

  The paging UI is a navigation bar that is a built into a single that spans across all columns of a control. The method is a helper method used by the class to create the pager row.

  This method is primarily used by control developers.

  Creates a object that contains the paging UI.

  The that contains the pager. The number of columns to span the pager. A that contains the properties for the pager. 1.0.5000.0 2.0.0.0
- Event
  System.Web.UI.WebControls.DataGridCommandEventHandler

  The event is raised when any button is clicked in the control. This event is commonly used to handle buttons controls with a custom CommandName value, such as Add, in the control.

  For more information about handling events, see [<topic://cpconEventsOverview>].

  Occurs when any button is clicked in the control.

  1.0.5000.0
  2.0.0.0
- Event
  System.Web.UI.WebControls.DataGridItemEventHandler

  The event is raised when an item in the control is created, both during round-trips and at the time data is bound to the control.

  The event is commonly used to control the content and appearance of a row in the control.

  For more information about handling events, see [<topic://cpconEventsOverview>].

  Occurs on the server when an item in the control is created.

  1.0.5000.0
  2.0.0.0
- Event
  System.Web.UI.WebControls.DataGridItemEventHandler

  The event is raised after an item is data bound to the 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 nulled out and no longer available.

  For more information about handling events, see [<topic://cpconEventsOverview>].

  Occurs after an item is data bound to the control.

  1.0.5000.0
  2.0.0.0
- Property
  System.Web.UI.WebControls.DataGridItemCollection To be added: an object of type 'DataGridItemCollection'

  Use the collection to programmatically control the items in the control. The 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 event.

  Only items bound to the data source are contained in the collection. The header, footer, and separator are not included in the collection.

  Gets a collection of objects that represent the individual items in the control.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.ComponentModel.Browsable(false)
- Property
  System.Web.UI.WebControls.TableItemStyle To be added: an object of type 'TableItemStyle'

  Use this property to provide a custom style for the items of the control. Common style attributes that can be adjusted include forecolor, backcolor, font, and content alignment within the cell. Providing a different style enhances the appearance of the control.

  Item style properties in the 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 property, all other item style properties in the 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 property, overriding the red font specified in the property. The following table lists the hierarchy order from highest to lowest.

  Precedence

  Style Property

  1

  2

  3

  4

  5

  To specify a custom style for the items of the control, place the <ItemStyle> tags between the opening and closing tags of the control. You can then list the style attributes within the opening <ItemStyle> tag.

  You can also use the property to provide a different appearance for the alternating items in the control.

  Gets the style properties of the items in the control.

  1.0.5000.0
  2.0.0.0
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.ComponentModel.NotifyParentProperty(true)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
- Method
  System.Void `` To be added

  Loads a saved state of the .

  A saved state of the . 1.0.5000.0 2.0.0.0
- Field
  System.String

  Use the field to represent the Next command argument.

  Represents the Next command argument. This field is read-only.

  1.0.5000.0
  2.0.0.0
- Method
  System.Boolean `` ``

  Use the method to pass an event raised by a control within the container up the page's UI server control hierarchy.

  This method is primarily used by control developers.

  Passes the event raised by a control within the container up the page's UI server control hierarchy.

  true to indicate that this method is passing an event raised by a control within the container up the page's UI server control hierarchy; otherwise, false.

  The source of the event. An that contains event data. 1.0.5000.0 2.0.0.0
- Method
  System.Void ``

  Use the method to provide a custom handler for the event.

  The event is raised when the Cancel button is clicked for an item in the control.

  A typical handler for the event sets the property to -1 (to deselect the item) and then rebinds the data to the control.

  Text is not HTML encoded before it is displayed in the 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.

  Raising an event invokes the event handler through a delegate. For more information, see [<topic://cpconProvidingEventFunctionality>].

  Raises the event. This allows you to provide a custom handler for the event.

  A that contains event data. 1.0.5000.0 2.0.0.0
- Method
  System.Void ``

  Use the method to provide a custom handler for the event.

  The event is raised when the Delete button is clicked for an item in the control.

  A typical handler for the event removes the selected item from the data source and then rebinds the data to the control.

  Raising an event invokes the event handler through a delegate. For more information, see [<topic://cpconProvidingEventFunctionality>].

  Raises the event. This allows you to provide a custom handler for the event.

  A that contains event data. 1.0.5000.0 2.0.0.0
- Method
  System.Void ``

  Use the method to provide a custom handler for the event.

  The event is raised when the Edit button is clicked for an item in the control.

  A typical handler for the event sets the property to the selected row and then rebinds the data to the control.

  Raising an event invokes the event handler through a delegate. For more information, see [<topic://cpconProvidingEventFunctionality>].

  Text is not HTML encoded before it is displayed in the 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.

  Raises the event. This allows you to provide a custom handler for the event.

  A that contains event data. 1.0.5000.0 2.0.0.0
- Method
  System.Void ``

  Use the method to provide a custom handler for the event.

  The event is raised when any button is clicked in the control. This event is commonly used to handle buttons controls with a custom CommandName value, such as Add, in the control.

  Raising an event invokes the event handler through a delegate. For more information, see [<topic://cpconProvidingEventFunctionality>].

  Raises the event. This allows you to provide a custom handler for the event.

  A that contains event data. 1.0.5000.0 2.0.0.0
- Method
  System.Void ``

  Use the method to provide a custom handler for the event.

  The event is raised when an item in the control is created, both during round-trips and at the time data is bound to the control.

  The event is commonly used to control the content and appearance of a row in the control.

  Raising an event invokes the event handler through a delegate. For more information, see [<topic://cpconProvidingEventFunctionality>].

  Raises the event. This allows you to provide a custom handler for the event.

  A that contains event data. 1.0.5000.0 2.0.0.0
- Method
  System.Void ``

  Use the method to provide a custom handler for the event.

  The event is raised after an item is data bound to the 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 nulled out and no longer available.

  Raising an event invokes the event handler through a delegate. For more information, see [<topic://cpconProvidingEventFunctionality>].

  Raises the event. This allows you to provide a custom handler for the event.

  A that contains event data. 1.0.5000.0 2.0.0.0
- Method
  System.Void ``

  Use the method to provide a custom handler for the event.

  The event is raised when one of the page selection elements is clicked.

  A typical handler for the event sets the property to the index of the page you want to display and then uses the method to bind the data to the control.

  The event handler receives a object as a parameter. You can use the property of this parameter to determine the index of the page selected by the user from the page selection elements of the control.

  Raising an event invokes the event handler through a delegate. For more information, see [<topic://cpconProvidingEventFunctionality>].

  Raises the event. This allows you to provide a custom handler for the event.

  A that contains event data. 1.0.5000.0 2.0.0.0
- Method
  System.Void ``

  Use the method to provide a custom handler for the event.

  The event is raised when a column is sorted.

  A typical handler for the event sorts the list, and then rebinds the data to the control.

  Raising an event invokes the event handler through a delegate. For more information, see [<topic://cpconProvidingEventFunctionality>].

  Raises the event. This allows you to provide a custom handler for the event.

  A that contains event data. 1.0.5000.0 2.0.0.0
- Method
  System.Void ``

  Use the method to provide a custom handler for the event.

  The event is raised when the Update button for an item is clicked.

  A typical handler for the event updates the data, sets the property to -1 (to deselect the item), and then rebinds the data to the control.

  Text is not HTML encoded before it is displayed in the control. If the values for the control come from user input, be sure to validate the values to reduce security vulnerabilities.

  Raising an event invokes the event handler through a delegate. For more information, see [<topic://cpconProvidingEventFunctionality>].

  The 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.

  Raises the event. This allows you to provide a custom handler for the event.

  A that contains event data. 1.0.5000.0 2.0.0.0
- Field
  System.String

  Use the field to represent the Page command name.

  Represents the Page command name. This field is read-only.

  1.0.5000.0
  2.0.0.0
- Property
  System.Int32 To be added: an object of type 'int'

  Use this property to programmatically determine the number of pages required to display the items in the control. This property is only used when the property is set to true.

  Gets the total number of pages required to display the items in the control.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.ComponentModel.Browsable(false)
- Event
  System.Web.UI.WebControls.DataGridPageChangedEventHandler

  The event is raised when one of the page selection elements is clicked.

  A typical handler for the event sets the property to the index of the page you want to display and then uses the method to bind the data to the control.

  For more information about handling events, see [<topic://cpconEventsOverview>].

  Occurs when one of the page selection elements is clicked.

  1.0.5000.0
  2.0.0.0
- Property
  System.Web.UI.WebControls.DataGridPagerStyle To be added: an object of type 'DataGridPagerStyle'

  Use this property to provide a custom style for the paging section of the control. Common style attributes that can be adjusted include forecolor, backcolor, font, and content alignment within the cell. Providing a different style enhances the appearance of the control.

  To specify a custom style for the paging section, place the <PagerStyle> tags between the opening and closing tags of the control. You can then list the style attributes within the opening <PagerStyle> tag.

  Gets the style properties of the paging section of the control.

  1.0.5000.0
  2.0.0.0
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.ComponentModel.NotifyParentProperty(true)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
- Property
  System.Int32 To be added: an object of type 'int'

  Use this property to specify the number of items to display on a single page of the control. The property must be set to true for this property have any effect.

  Gets or sets the number of items to display on a single page of the control.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DefaultValue(10)
- Method
  System.Void

  The method is a helper method called by the control to set up the control hierarchy in the control before the control is rendered.

  Sets up the control hierarchy for this control.

  1.0.5000.0
  2.0.0.0
- Field
  System.String

  Use the field to represent the Prev command argument.

  Represents the Prev command argument. This field is read-only.

  1.0.5000.0
  2.0.0.0
- Method
  System.Object To be added

  Saves the current state of the .

  The saved state of the .

  1.0.5000.0
  2.0.0.0
- Field
  System.String

  Use the field to represent the Select command name.

  Represents the Select command name. This field is read-only.

  1.0.5000.0
  2.0.0.0
- Property
  System.Int32 To be added: an object of type 'int'

  Use the property to determine the index of the item selected by the user in the control. You can also use this property to programmatically specify which item is selected in the control.

  To deselect an item in the control, set this property to -1.

  Gets or sets the index of the selected item in the control.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DefaultValue(-1)
  System.ComponentModel.Bindable(true)
- Property
  System.Web.UI.WebControls.DataGridItem To be added: an object of type 'DataGridItem'

  Use the property to get a object that represents the selected item in the control. This object can then be used to access the properties of the selected item.

  Gets a object that represents the selected item in the control.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.ComponentModel.Browsable(false)
- Property
  System.Web.UI.WebControls.TableItemStyle To be added: an object of type 'TableItemStyle'

  Use the property to provide a custom style for the selected item in the control. Common style attributes that can be adjusted include forecolor, backcolor, font, and content alignment within the cell. Providing a different style enhances the appearance of the control.

  Item style properties in the 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 property, all other item style properties in the 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 property, overriding the red font specified in the property. The following table lists the hierarchy order from highest to lowest.

  Precedence

  Style Property

  1

  2

  3

  4

  5

  To specify a custom style for the selected item, place the <SelectedItemStyle> tags between the opening and closing tags of the control. You can then list the style attributes within the opening <SelectedItemStyle> tag.

  Gets the style properties of the currently selected item in the control.

  1.0.5000.0
  2.0.0.0
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.ComponentModel.NotifyParentProperty(true)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
- Property
  System.Boolean To be added: an object of type 'bool'

  Set this property to true to display the footer in the control. The appearance of the footer is controlled by using the property.

  Gets or sets a value that indicates whether the footer is displayed in the control.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DefaultValue(false)
- Property
  System.Boolean To be added: an object of type 'bool'

  Set this property to true to display the header in the . The appearance of the header is controlled by using the property.

  Gets or sets a value that indicates whether the header is displayed in the control.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DefaultValue(true)
- Event
  System.Web.UI.WebControls.DataGridSortCommandEventHandler

  The event is raised when a column is sorted.

  A typical handler for the event sorts the list, and then rebinds the data to the control.

  For more information about handling events, see [<topic://cpconEventsOverview>].

  Occurs when a column is sorted.

  1.0.5000.0
  2.0.0.0
- Field
  System.String

  Use the field to represent the Sort command name.

  Represents the Sort command name. This field is read-only.

  1.0.5000.0
  2.0.0.0
- Property
  1.0.5000.0
  2.0.0.0
  System.Web.UI.HtmlTextWriterTag To be added.

  The property allows the output stream to write the appropriate HTML markup for the control.

  Gets the value for the control.

- Method
  System.Void To be added

  Marks the starting point to begin tracking and saving changes to the control as part of the control view state.

  1.0.5000.0
  2.0.0.0
- Event
  System.Web.UI.WebControls.DataGridCommandEventHandler

  The event is raised when the Update button for an item is clicked.

  A typical handler for the event updates the data, sets the property to -1 (to deselect the item), and then rebinds the data to the control.

  Text is not HTML encoded before it is displayed in the 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 [<topic://cpconEventsOverview>].

  Occurs when the Update button is clicked for an item in the control.

  1.0.5000.0
  2.0.0.0
- Field
  System.String

  Use the field to represent the Update command name.

  Represents the Update command name. This field is read-only.

  1.0.5000.0
  2.0.0.0
- Property
  System.Int32 To be added: an object of type 'int'

  Use this property to specify the virtual number of items in the control when custom paging is used. This property is only used when the property is set to true.

  If the property is set to true, the number of pages required to display every item in the control is calculated based on the values of the and properties.

  If the property is set to false, the number of pages displayed in the control is calculated based on the values of the property and the total number of items in the data source.

  Gets or sets the virtual number of items in the control when custom paging is used.

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.ComponentModel.Browsable(false)