Bewerken

Delen via


GridView Class

Definition

Displays the values of a data source in a table where each column represents a field and each row represents a record. The GridView control enables you to select, sort, and edit these items.

public ref class GridView : System::Web::UI::WebControls::CompositeDataBoundControl, System::Web::UI::ICallbackEventHandler, System::Web::UI::IPostBackEventHandler, System::Web::UI::WebControls::ICallbackContainer, System::Web::UI::WebControls::IPersistedSelector, System::Web::UI::WebControls::IPostBackContainer
public ref class GridView : System::Web::UI::WebControls::CompositeDataBoundControl, System::Web::UI::ICallbackEventHandler, System::Web::UI::IDataKeysControl, System::Web::UI::IPostBackEventHandler, System::Web::UI::WebControls::ICallbackContainer, System::Web::UI::WebControls::IDataBoundListControl, System::Web::UI::WebControls::IFieldControl, System::Web::UI::WebControls::IPersistedSelector, System::Web::UI::WebControls::IPostBackContainer
[System.Web.UI.ControlValueProperty("SelectedValue")]
public class GridView : System.Web.UI.WebControls.CompositeDataBoundControl, System.Web.UI.ICallbackEventHandler, System.Web.UI.IPostBackEventHandler, System.Web.UI.WebControls.ICallbackContainer, System.Web.UI.WebControls.IPersistedSelector, System.Web.UI.WebControls.IPostBackContainer
[System.Web.UI.ControlValueProperty("SelectedValue")]
public class GridView : System.Web.UI.WebControls.CompositeDataBoundControl, System.Web.UI.ICallbackEventHandler, System.Web.UI.IDataKeysControl, System.Web.UI.IPostBackEventHandler, System.Web.UI.WebControls.ICallbackContainer, System.Web.UI.WebControls.IDataBoundListControl, System.Web.UI.WebControls.IFieldControl, System.Web.UI.WebControls.IPersistedSelector, System.Web.UI.WebControls.IPostBackContainer
[<System.Web.UI.ControlValueProperty("SelectedValue")>]
type GridView = class
    inherit CompositeDataBoundControl
    interface IPostBackContainer
    interface IPostBackEventHandler
    interface ICallbackContainer
    interface ICallbackEventHandler
    interface IPersistedSelector
[<System.Web.UI.ControlValueProperty("SelectedValue")>]
type GridView = class
    inherit CompositeDataBoundControl
    interface IPostBackContainer
    interface IPostBackEventHandler
    interface ICallbackContainer
    interface ICallbackEventHandler
    interface IPersistedSelector
    interface IDataKeysControl
    interface IDataBoundListControl
    interface IDataBoundControl
    interface IFieldControl
Public Class GridView
Inherits CompositeDataBoundControl
Implements ICallbackContainer, ICallbackEventHandler, IPersistedSelector, IPostBackContainer, IPostBackEventHandler
Public Class GridView
Inherits CompositeDataBoundControl
Implements ICallbackContainer, ICallbackEventHandler, IDataBoundListControl, IDataKeysControl, IFieldControl, IPersistedSelector, IPostBackContainer, IPostBackEventHandler
Inheritance
Attributes
Implements

Examples

A Visual Studio Web site project with source code is available to accompany this topic: Download.

The following example demonstrates how use the GridView control to display the values from the Customers table of the AdventureWorksLT sample database in Microsoft SQL Server. The values are retrieved using a SqlDataSource control.

<asp:sqldatasource id="CustomersSource"
  selectcommand="SELECT CustomerID, CompanyName, FirstName, LastName FROM SalesLT.Customer"
  connectionstring="<%$ ConnectionStrings:AWLTConnectionString %>" 
  runat="server"/>

<asp:gridview id="CustomersGridView" 
  datasourceid="CustomersSource" 
  autogeneratecolumns="False"
  emptydatatext="No data available." 
  allowpaging="True" 
  runat="server" DataKeyNames="CustomerID">
    <Columns>
        <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" 
            InsertVisible="False" ReadOnly="True" SortExpression="CustomerID" />
        <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" 
            SortExpression="CompanyName" />
        <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
            SortExpression="FirstName" />
        <asp:BoundField DataField="LastName" HeaderText="LastName" 
            SortExpression="LastName" />
    </Columns>
</asp:gridview>
<asp:sqldatasource id="CustomersSource"
  selectcommand="SELECT CustomerID, CompanyName, FirstName, LastName FROM SalesLT.Customer"
  connectionstring="<%$ ConnectionStrings:AWLTConnectionString %>" 
  runat="server"/>

<asp:gridview id="CustomersGridView" 
  datasourceid="CustomersSource" 
  autogeneratecolumns="False"
  emptydatatext="No data available." 
  allowpaging="True" 
  runat="server" DataKeyNames="CustomerID">
    <Columns>
        <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" 
            InsertVisible="False" ReadOnly="True" SortExpression="CustomerID" />
        <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" 
            SortExpression="CompanyName" />
        <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
            SortExpression="FirstName" />
        <asp:BoundField DataField="LastName" HeaderText="LastName" 
            SortExpression="LastName" />
    </Columns>
</asp:gridview>

The following example demonstrates how to use the GridView control and a LinqDataSource control so that you can edit records.

<asp:LinqDataSource ID="LinqDataSource1" runat="server" 
    ContextTypeName="AdventureWorksLTDataClassesDataContext"
    EnableDelete="True" EnableInsert="True" EnableUpdate="True" 
    TableName="SalesOrderDetails">
</asp:LinqDataSource>

<asp:GridView ID="GridView1" runat="server" 
    AutoGenerateColumns="False" 
    DataKeyNames="SalesOrderID,SalesOrderDetailID"
    DataSourceID="LinqDataSource1">
    <Columns>
        <asp:CommandField ShowDeleteButton="True" 
            ShowEditButton="True" />
        <asp:BoundField DataField="SalesOrderID" 
            HeaderText="SalesOrderID" ReadOnly="True"
            SortExpression="SalesOrderID" />
        <asp:BoundField DataField="SalesOrderDetailID" 
            HeaderText="SalesOrderDetailID" InsertVisible="False"
            ReadOnly="True" SortExpression="SalesOrderDetailID" />
        <asp:BoundField DataField="OrderQty" 
            HeaderText="OrderQty" SortExpression="OrderQty" />
        <asp:BoundField DataField="ProductID" 
            HeaderText="ProductID" SortExpression="ProductID" />
        <asp:BoundField DataField="UnitPrice" 
            HeaderText="UnitPrice" SortExpression="UnitPrice" />
        <asp:BoundField DataField="ModifiedDate" 
            HeaderText="ModifiedDate" SortExpression="ModifiedDate" />
    </Columns>
</asp:GridView>
<asp:LinqDataSource ID="LinqDataSource1" runat="server" 
    ContextTypeName="AdventureWorksLTDataClassesDataContext"
    EnableDelete="True" EnableInsert="True" EnableUpdate="True" 
    TableName="SalesOrderDetails">
</asp:LinqDataSource>

<asp:GridView ID="GridView1" runat="server" 
    AutoGenerateColumns="False" 
    DataKeyNames="SalesOrderID,SalesOrderDetailID"
    DataSourceID="LinqDataSource1">
    <Columns>
        <asp:CommandField ShowDeleteButton="True" 
            ShowEditButton="True" />
        <asp:BoundField DataField="SalesOrderID" 
            HeaderText="SalesOrderID" ReadOnly="True"
            SortExpression="SalesOrderID" />
        <asp:BoundField DataField="SalesOrderDetailID" 
            HeaderText="SalesOrderDetailID" InsertVisible="False"
            ReadOnly="True" SortExpression="SalesOrderDetailID" />
        <asp:BoundField DataField="OrderQty" 
            HeaderText="OrderQty" SortExpression="OrderQty" />
        <asp:BoundField DataField="ProductID" 
            HeaderText="ProductID" SortExpression="ProductID" />
        <asp:BoundField DataField="UnitPrice" 
            HeaderText="UnitPrice" SortExpression="UnitPrice" />
        <asp:BoundField DataField="ModifiedDate" 
            HeaderText="ModifiedDate" SortExpression="ModifiedDate" />
    </Columns>
</asp:GridView>

For an example demonstrating how to access values in cells, see GridViewRow.

Remarks

In this topic:

Introduction

The GridView control is used to display the values of a data source in a table. Each column represents a field, while each row represents a record. The GridView control supports the following features:

  • Binding to data source controls, such as SqlDataSource.

  • Built-in sort capabilities.

  • Built-in update and delete capabilities.

  • Built-in paging capabilities.

  • Built-in row selection capabilities.

  • Programmatic access to the GridView object model to dynamically set properties, handle events, and so on.

  • Multiple key fields.

  • Multiple data fields for the hyperlink columns.

  • Customizable appearance through themes and styles.

  • To learn about the other data-bound controls that are available in ASP.NET, see Data-Bound Web Server Controls.

Note

If you are familiar with the DataGrid control from the .NET Framework version 1.0, the GridView control is the successor to the DataGrid control.

Column Fields

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

You can also manually control which column fields appear in the GridView control by setting the AutoGenerateColumns property to false and then defining your own column field collection. Different column field types determine the behavior of the columns in the control. The following table lists the different column field types that can be used.

Column field type Description
BoundField Displays the value of a field in a data source. This is the default column type of the GridView control.
ButtonField Displays a command button for each item in the GridView control. This enables you to create a column of custom button controls, such as the Add or the Remove button.
CheckBoxField Displays a check box for each item in the GridView control. This column field type is commonly used to display fields with a Boolean value.
CommandField Displays predefined command buttons to perform select, edit, or delete operations.
HyperLinkField Displays the value of a field in a data source as a hyperlink. This column field type enables you to bind a second field to the hyperlink's URL.
ImageField Displays an image for each item in the GridView control.
TemplateField Displays user-defined content for each item in the GridView control according to a specified template. This column field type enables you to create a custom column field.

To define a column field collection declaratively, first add opening and closing <Columns> tags between the opening and closing tags of the GridView control. Next, list the column fields that you want to include between the opening and closing <Columns> tags. The columns specified are added to the Columns collection in the order listed. The Columns collection stores all the column fields in the control and enables you to programmatically manage the column fields in the GridView control.

Explicitly declared column fields can be displayed in combination with automatically generated column fields. When both are used, explicitly declared column fields are rendered first, followed by the automatically generated column fields.

Note

Automatically generated column fields are not added to the Columns collection.

Binding to Data

The GridView control can be bound to a data source control (such as the SqlDataSource control or ObjectDataSource control) or to any data source collection that implements the System.Collections.IEnumerable interface, such as System.Data.DataView, System.Collections.ArrayList, System.Collections.Generic.List<T>, or other collection types. Use one of the following methods to bind the GridView control to the appropriate data source type:

  • To bind to a data source control, set the DataSourceID property of the GridView control to the ID value of the data source control. The GridView control automatically binds to the specified data source control and can take advantage of the data source control's capabilities to perform sorting, updating, deleting, and paging. This is the preferred method to bind to data.

  • To bind to a data source that implements the System.Collections.IEnumerable interface, programmatically set the DataSource property of the GridView control to the data source and then call the DataBind method. When using this method, the GridView control does not provide built-in sort, update, delete, and paging functionality. You need to provide this functionality by using the appropriate event.

For more information about data binding, see ASP.NET Data Access Content Map.

Note

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. Whenever possible, it is strongly recommended that values are HTML-encoded before they are displayed in this control (the BoundField class HTML-encodes values by default). 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 Introduction to the Validation Controls.

Data Operations

The GridView control provides many built-in capabilities that allow the user to sort, update, delete, select, and page through items in the control. When the GridView control is bound to a data source control, the GridView control can take advantage of the data source control's capabilities and provide automatic sort, update, and delete functionality.

Note

The GridView control can provide support for sorting, updating, and deleting with other types of data sources. However, you will need to provide an appropriate event handler with the implementation for these operations.

Sorting allows the user to sort the items in the GridView control with respect to a specific column by clicking on the column's header. To enable sorting, set the AllowSorting property to true.

The automatic updating, deleting, and selection functionalities are enabled when a button in a ButtonField or TemplateField column field, with a command name of "Edit", "Delete", and "Select", respectively, is clicked. The GridView control can automatically add a CommandField column field with an Edit, Delete, or Select button if the AutoGenerateEditButton, AutoGenerateDeleteButton, or AutoGenerateSelectButton property is set to true, respectively.

Note

Inserting records into the data source is not directly supported by the GridView control. However, it is possible to insert records by using the GridView control in conjunction with the DetailsView or FormView control. For more information, see DetailsView or FormView, respectively.

Instead of displaying all the records in the data source at the same time, the GridView control can automatically break the records up into pages. To enable paging, set the AllowPaging property to true.

Note

The GridView control is re-created on postback based on the information that is stored in ViewState. If the GridView control includes a TemplateField or a CommandField with the CausesValidation property set to true, then the EnableViewState property must also be set to true to ensure that concurrent data operations, such as updates and deletes, apply to the appropriate row.

Customizing the User Interface

You can customize the appearance of the GridView control by setting the style properties for the different parts of the control. The following table lists the different style properties.

Style property Description
AlternatingRowStyle The style settings for the alternating data rows in the GridView control. When this property is set, the data rows are displayed alternating between the RowStyle settings and the AlternatingRowStyle settings.
EditRowStyle The style settings for the row being edited in the GridView control.
EmptyDataRowStyle The style settings for the empty data row displayed in the GridView control when the data source does not contain any records.
FooterStyle The style settings for the footer row of the GridView control.
HeaderStyle The style settings for the header row of the GridView control.
PagerStyle The style settings for the pager row of the GridView control.
RowStyle The style settings for the data rows in the GridView control. When the AlternatingRowStyle property is also set, the data rows are displayed alternating between the RowStyle settings and the AlternatingRowStyle settings.
SelectedRowStyle The style settings for the selected row in the GridView control.
SortedAscendingCellStyle The style setting for the data column the data is sorted by in the GridView control. When this style is set, the style (for example, highlighted column) is applied to cells when the data is sorted in ascending order.
SortedAscendingHeaderStyle The style setting for the data column the data is sorted by in the GridView control. When this style is set, an arrow indicating the data is sorted ascending is placed on the header of the GridView control when the data is sorted in ascending order.
SortedDescendingCellStyle The style setting for the data column the data is sorted by in the GridView control. When this style is set, the style (for example, highlighted column) is applied to cells when the data is sorted in descending order.
SortedDescendingHeaderStyle The style setting for the data column the data is sorted by in the GridView control. When this style is set, an arrow pointing down is placed on the header of the GridView when the data is sorted in descending order.

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
ShowFooter Shows or hides the footer section of the GridView control.
ShowHeader Shows or hides the header section of the GridView control.

Events

The GridView control provides several events that you can program against. This enables you to run a custom routine whenever an event occurs. The following table lists the events that are supported by the GridView control.

Event Description
PageIndexChanged Occurs when one of the pager buttons is clicked, but after the GridView control handles the paging operation. This event is commonly used when you need to perform a task after the user navigates to a different page in the control.
PageIndexChanging Occurs when one of the pager buttons is clicked, but before the GridView control handles the paging operation. This event is often used to cancel the paging operation.
RowCancelingEdit Occurs when a row's Cancel button is clicked, but before the GridView control exits edit mode. This event is often used to stop the canceling operation.
RowCommand Occurs when a button is clicked in the GridView control. This event is often used to perform a task when a button is clicked in the control.
RowCreated Occurs when a new row is created in the GridView control. This event is often used to modify the contents of a row when the row is created.
RowDataBound Occurs when a data row is bound to data in the GridView control. This event is often used to modify the contents of a row when the row is bound to data.
RowDeleted Occurs when a row's Delete button is clicked, but after the GridView control deletes the record from the data source. This event is often used to check the results of the delete operation.
RowDeleting Occurs when a row's Delete button is clicked, but before the GridView control deletes the record from the data source. This event is often used to cancel the deleting operation.
RowEditing Occurs when a row's Edit button is clicked, but before the GridView control enters edit mode. This event is often used to cancel the editing operation.
RowUpdated Occurs when a row's Update button is clicked, but after the GridView control updates the row. This event is often used to check the results of the update operation.
RowUpdating Occurs when a row's Update button is clicked, but before the GridView control updates the row. This event is often used to cancel the updating operation.
SelectedIndexChanged Occurs when a row's Select button is clicked, but after the GridView control handles the select operation. This event is often used to perform a task after a row is selected in the control.
SelectedIndexChanging Occurs when a row's Select button is clicked, but before the GridView control handles the select operation. This event is often used to cancel the selection operation.
Sorted Occurs when the hyperlink to sort a column is clicked, but after the GridView control handles the sort operation. This event is commonly used to perform a task after the user clicks a hyperlink to sort a column.
Sorting Occurs when the hyperlink to sort a column is clicked, but before the GridView control handles the sort operation. This event is often used to cancel the sorting operation or to perform a custom sorting routine.

Accessibility

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

Declarative Syntax

<asp:GridView  
    AccessKey="string"  
    AllowPaging="True|False"  
    AllowSorting="True|False"  
    AutoGenerateColumns="True|False"  
    AutoGenerateDeleteButton="True|False"  
    AutoGenerateEditButton="True|False"  
    AutoGenerateSelectButton="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"  
    DataKeyNames="string"  
    DataMember="string"  
    DataSource="string"  
    DataSourceID="string"  
    EditIndex="integer"  
    EmptyDataText="string"  
    Enabled="True|False"  
    EnableSortingAndPagingCallbacks="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"  
    OnDataBinding="DataBinding event handler"  
    OnDataBound="DataBound event handler"  
    OnDisposed="Disposed event handler"  
    OnInit="Init event handler"  
    OnLoad="Load event handler"  
    OnPageIndexChanged="PageIndexChanged event handler"  
    OnPageIndexChanging="PageIndexChanging event handler"  
    OnPreRender="PreRender event handler"  
    OnRowCancelingEdit="RowCancelingEdit event handler"  
    OnRowCommand="RowCommand event handler"  
    OnRowCreated="RowCreated event handler"  
    OnRowDataBound="RowDataBound event handler"  
    OnRowDeleted="RowDeleted event handler"  
    OnRowDeleting="RowDeleting event handler"  
    OnRowEditing="RowEditing event handler"  
    OnRowUpdated="RowUpdated event handler"  
    OnRowUpdating="RowUpdating event handler"  
    OnSelectedIndexChanged="SelectedIndexChanged event handler"  
    OnSelectedIndexChanging="SelectedIndexChanging event handler"  
    OnSorted="Sorted event handler"  
    OnSorting="Sorting event handler"  
    OnUnload="Unload event handler"  
    PageIndex="integer"  
    PagerSettings-FirstPageImageUrl="uri"  
    PagerSettings-FirstPageText="string"  
    PagerSettings-LastPageImageUrl="uri"  
    PagerSettings-LastPageText="string"  
    PagerSettings-Mode="NextPrevious|Numeric|NextPreviousFirstLast|  
        NumericFirstLast"  
    PagerSettings-NextPageImageUrl="uri"  
    PagerSettings-NextPageText="string"  
    PagerSettings-PageButtonCount="integer"  
    PagerSettings-Position="Bottom|Top|TopAndBottom"  
    PagerSettings-PreviousPageImageUrl="uri"  
    PagerSettings-PreviousPageText="string"  
    PagerSettings-Visible="True|False"  
    PageSize="integer"  
    RowHeaderColumn="string"  
    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"  
>  
        <AlternatingRowStyle />  
        <Columns>  
                <asp:BoundField  
                    AccessibleHeaderText="string"  
                    ApplyFormatInEditMode="True|False"  
                    ConvertEmptyStringToNull="True|False"  
                    DataField="string"  
                    DataFormatString="string"  
                    FooterText="string"  
                    HeaderImageUrl="uri"  
                    HeaderText="string"  
                    HtmlEncode="True|False"  
                    InsertVisible="True|False"  
                    NullDisplayText="string"  
                    ReadOnly="True|False"  
                    ShowHeader="True|False"  
                    SortExpression="string"  
                    Visible="True|False"  
>  
                        <ControlStyle />  
                        <FooterStyle />  
                        <HeaderStyle />  
                        <ItemStyle />  
                </asp:BoundField>  
                <asp:ButtonField  
                    AccessibleHeaderText="string"  
                    ButtonType="Button|Image|Link"  
                    CausesValidation="True|False"  
                    CommandName="string"  
                    DataTextField="string"  
                    DataTextFormatString="string"  
                    FooterText="string"  
                    HeaderImageUrl="uri"  
                    HeaderText="string"  
                    ImageUrl="uri"  
                    InsertVisible="True|False"  
                    ShowHeader="True|False"  
                    SortExpression="string"  
                    Text="string"  
                    ValidationGroup="string"  
                    Visible="True|False"  
>  
                        <ControlStyle />  
                        <FooterStyle />  
                        <HeaderStyle />  
                        <ItemStyle />  
                </asp:ButtonField>  
                <asp:CheckBoxField  
                    AccessibleHeaderText="string"  
                    DataField="string"  
                    FooterText="string"  
                    HeaderImageUrl="uri"  
                    HeaderText="string"  
                    InsertVisible="True|False"  
                    ReadOnly="True|False"  
                    ShowHeader="True|False"  
                    SortExpression="string"  
                    Text="string"  
                    Visible="True|False"  
>  
                        <ControlStyle />  
                        <FooterStyle />  
                        <HeaderStyle />  
                        <ItemStyle />  
                </asp:CheckBoxField>  
                <asp:CommandField  
                    AccessibleHeaderText="string"  
                    ButtonType="Button|Image|Link"  
                    CancelImageUrl="uri"  
                    CancelText="string"  
                    CausesValidation="True|False"  
                    DeleteImageUrl="uri"  
                    DeleteText="string"  
                    EditImageUrl="uri"  
                    EditText="string"  
                    FooterText="string"  
                    HeaderImageUrl="uri"  
                    HeaderText="string"  
                    InsertImageUrl="uri"  
                    InsertText="string"  
                    InsertVisible="True|False"  
                    NewImageUrl="uri"  
                    NewText="string"  
                    SelectImageUrl="uri"  
                    SelectText="string"  
                    ShowCancelButton="True|False"  
                    ShowDeleteButton="True|False"  
                    ShowEditButton="True|False"  
                    ShowHeader="True|False"  
                    ShowInsertButton="True|False"  
                    ShowSelectButton="True|False"  
                    SortExpression="string"  
                    UpdateImageUrl="uri"  
                    UpdateText="string"  
                    ValidationGroup="string"  
                    Visible="True|False"  
>  
                        <ControlStyle />  
                        <FooterStyle />  
                        <HeaderStyle />  
                        <ItemStyle />  
                </asp:CommandField>  
                <asp:DynamicField  
                    AccessibleHeaderText="string"  
                    ApplyFormatInEditMode="True|False"  
                    ConvertEmptyStringToNull="True|False"  
                    DataField="string"  
                    DataFormatString="string"  
                    FooterText="string"  
                    HeaderImageUrl="uri"  
                    HeaderText="string"  
                    HtmlEncode="True|False"  
                    InsertVisible="True|False"  
                    NullDisplayText="string"  
                    ShowHeader="True|False"  
                    UIHint="string"  
                    Visible="True|False"  
>  
                        <ControlStyle />  
                        <FooterStyle />  
                        <HeaderStyle />  
                        <ItemStyle />  
                </asp:DynamicField>  
                <asp:HyperLinkField  
                    AccessibleHeaderText="string"  
                    DataNavigateUrlFields="string"  
                    DataNavigateUrlFormatString="string"  
                    DataTextField="string"  
                    DataTextFormatString="string"  
                    FooterText="string"  
                    HeaderImageUrl="uri"  
                    HeaderText="string"  
                    InsertVisible="True|False"  
                    NavigateUrl="uri"  
                    ShowHeader="True|False"  
                    SortExpression="string"  
                    Target="string|_blank|_parent|_search|_self|_top"  
                    Text="string"  
                    Visible="True|False"  
>  
                        <ControlStyle />  
                        <FooterStyle />  
                        <HeaderStyle />  
                        <ItemStyle />  
                </asp:HyperLinkField>  
                <asp:ImageField  
                    AccessibleHeaderText="string"  
                    AlternateText="string"  
                    ConvertEmptyStringToNull="True|False"  
                    DataAlternateTextField="string"  
                    DataAlternateTextFormatString="string"  
                    DataImageUrlField="string"  
                    DataImageUrlFormatString="string"  
                    FooterText="string"  
                    HeaderImageUrl="uri"  
                    HeaderText="string"  
                    InsertVisible="True|False"  
                    NullDisplayText="string"  
                    NullImageUrl="uri"  
                    ReadOnly="True|False"  
                    ShowHeader="True|False"  
                    SortExpression="string"  
                    Visible="True|False"  
>  
                        <ControlStyle />  
                        <FooterStyle />  
                        <HeaderStyle />  
                        <ItemStyle />  
                </asp:ImageField>  
                <asp:TemplateField  
                    AccessibleHeaderText="string"  
                    ConvertEmptyStringToNull="True|False"  
                    FooterText="string"  
                    HeaderImageUrl="uri"  
                    HeaderText="string"  
                    InsertVisible="True|False"  
                    ShowHeader="True|False"  
                    SortExpression="string"  
                    Visible="True|False"  
>  
                            <ControlStyle />  
                            <FooterStyle />  
                            <HeaderStyle />  
                            <ItemStyle />  
                        <AlternatingItemTemplate>  
                            <!-- child controls -->  
                        </AlternatingItemTemplate>  
                        <EditItemTemplate>  
                            <!-- child controls -->  
                        </EditItemTemplate>  
                        <FooterTemplate>  
                            <!-- child controls -->  
                        </FooterTemplate>  
                        <HeaderTemplate>  
                            <!-- child controls -->  
                        </HeaderTemplate>  
                        <InsertItemTemplate>  
                            <!-- child controls -->  
                        </InsertItemTemplate>  
                        <ItemTemplate>  
                            <!-- child controls -->  
                        </ItemTemplate>  
                </asp:TemplateField>  
        </Columns>  
        <EditRowStyle />  
        <EmptyDataRowStyle />  
        <EmptyDataTemplate>  
            <!-- child controls -->  
        </EmptyDataTemplate>  
        <FooterStyle />  
        <HeaderStyle />  
        <PagerSettings  
            FirstPageImageUrl="uri"  
            FirstPageText="string"  
            LastPageImageUrl="uri"  
            LastPageText="string"  
            Mode="NextPrevious|Numeric|NextPreviousFirstLast|  
                NumericFirstLast"  
            NextPageImageUrl="uri"  
            NextPageText="string"  
            OnPropertyChanged="PropertyChanged event handler"  
            PageButtonCount="integer"  
            Position="Bottom|Top|TopAndBottom"  
            PreviousPageImageUrl="uri"  
            PreviousPageText="string"  
            Visible="True|False"  
        />  
        <PagerStyle />  
        <PagerTemplate>  
            <!-- child controls -->  
        </PagerTemplate>  
        <RowStyle />  
        <SelectedRowStyle />  
</asp:GridView>  

Constructors

GridView()

Initializes a new instance of the GridView class.

Properties

AccessKey

Gets or sets the access key that allows you to quickly navigate to the Web server control.

(Inherited from WebControl)
Adapter

Gets the browser-specific adapter for the control.

(Inherited from Control)
AllowCustomPaging

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

AllowPaging

Gets or sets a value indicating whether the paging feature is enabled.

AllowSorting

Gets or sets a value indicating whether the sorting feature is enabled.

AlternatingRowStyle

Gets a reference to the TableItemStyle object that enables you to set the appearance of alternating data rows in a GridView control.

AppRelativeTemplateSourceDirectory

Gets or sets the application-relative virtual directory of the Page or UserControl object that contains this control.

(Inherited from Control)
Attributes

Gets the collection of arbitrary attributes (for rendering only) that do not correspond to properties on the control.

(Inherited from WebControl)
AutoGenerateColumns

Gets or sets a value indicating whether bound fields are automatically created for each field in the data source.

AutoGenerateDeleteButton

Gets or sets a value indicating whether a CommandField field column with a Delete button for each data row is automatically added to a GridView control.

AutoGenerateEditButton

Gets or sets a value indicating whether a CommandField field column with an Edit button for each data row is automatically added to a GridView control.

AutoGenerateSelectButton

Gets or sets a value indicating whether a CommandField field column with a Select button for each data row is automatically added to a GridView control.

BackColor

Gets or sets the background color of the Web server control.

(Inherited from WebControl)
BackImageUrl

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

BindingContainer

Gets the control that contains this control's data binding.

(Inherited from Control)
BorderColor

Gets or sets the border color of the Web control.

(Inherited from WebControl)
BorderStyle

Gets or sets the border style of the Web server control.

(Inherited from WebControl)
BorderWidth

Gets or sets the border width of the Web server control.

(Inherited from WebControl)
BottomPagerRow

Gets a GridViewRow object that represents the bottom pager row in a GridView control.

Caption

Gets or sets the text to render in an HTML caption element in a GridView control. This property is provided to make the control more accessible to users of assistive technology devices.

CaptionAlign

Gets or sets the horizontal or vertical position of the HTML caption element in a GridView control. This property is provided to make the control more accessible to users of assistive technology devices.

CellPadding

Gets or sets the amount of space between the contents of a cell and the cell's border.

CellSpacing

Gets or sets the amount of space between cells.

ChildControlsCreated

Gets a value that indicates whether the server control's child controls have been created.

(Inherited from Control)
ClientID

Gets the control ID for HTML markup that is generated by ASP.NET.

(Inherited from Control)
ClientIDMode

Gets or sets the algorithm that is used to generate the value of the ClientID property.

(Inherited from Control)
ClientIDRowSuffix

Gets or sets the names of the data fields whose values are appended to the ClientID property value to uniquely identify each instance of a data-bound control.

ClientIDRowSuffixDataKeys

Gets the data values that are used to uniquely identify each instance of a data-bound control when ASP.NET generates the ClientID value.

ClientIDSeparator

Gets a character value representing the separator character used in the ClientID property.

(Inherited from Control)
Columns

Gets a collection of DataControlField objects that represent the column fields in a GridView control.

ColumnsGenerator

Gets or sets the control that will automatically generate the columns for a GridView control that uses ASP.NET Dynamic Data features.

Context

Gets the HttpContext object associated with the server control for the current Web request.

(Inherited from Control)
Controls

Gets a collection of the child controls within the composite data-bound control.

(Inherited from CompositeDataBoundControl)
ControlStyle

Gets the style of the Web server control. This property is used primarily by control developers.

(Inherited from WebControl)
ControlStyleCreated

Gets a value indicating whether a Style object has been created for the ControlStyle property. This property is primarily used by control developers.

(Inherited from WebControl)
CssClass

Gets or sets the Cascading Style Sheet (CSS) class rendered by the Web server control on the client.

(Inherited from WebControl)
DataItemContainer

Gets a reference to the naming container if the naming container implements IDataItemContainer.

(Inherited from Control)
DataKeyNames

Gets or sets an array that contains the names of the primary key fields for the items displayed in a GridView control.

DataKeys

Gets a collection of DataKey objects that represent the data key value of each row in a GridView control.

DataKeysContainer

Gets a reference to the naming container if the naming container implements IDataKeysControl.

(Inherited from Control)
DataMember

Gets or sets the name of the list of data that the data-bound control binds to, in cases where the data source contains more than one distinct list of data items.

(Inherited from DataBoundControl)
DataSource

Gets or sets the object from which the data-bound control retrieves its list of data items.

(Inherited from BaseDataBoundControl)
DataSourceID

Gets or sets the ID of the control from which the data-bound control retrieves its list of data items.

(Inherited from DataBoundControl)
DataSourceObject

Gets an object that implements the IDataSource interface, which provides access to the object's data content.

(Inherited from DataBoundControl)
DeleteMethod

Gets or sets the name of the method to call in order to delete data.

DeleteMethod

Gets or sets the name of the method to call in order to delete data.

(Inherited from CompositeDataBoundControl)
DesignMode

Gets a value indicating whether a control is being used on a design surface.

(Inherited from Control)
EditIndex

Gets or sets the index of the row to edit.

EditRowStyle

Gets a reference to the TableItemStyle object that enables you to set the appearance of the row selected for editing in a GridView control.

EmptyDataRowStyle

Gets a reference to the TableItemStyle object that enables you to set the appearance of the empty data row rendered when a GridView control is bound to a data source that does not contain any records.

EmptyDataTemplate

Gets or sets the user-defined content for the empty data row rendered when a GridView control is bound to a data source that does not contain any records.

EmptyDataText

Gets or sets the text to display in the empty data row rendered when a GridView control is bound to a data source that does not contain any records.

Enabled

Gets or sets a value indicating whether the Web server control is enabled.

(Inherited from WebControl)
EnableModelValidation

Gets or sets a value that indicates whether a validator control will handle exceptions that occur during insert or update operations.

EnablePersistedSelection

Gets or sets a value that indicates whether the selection of a row is based on index or on data-key values.

EnableSortingAndPagingCallbacks

Gets or sets a value indicating whether client-side callbacks are used for sorting and paging operations.

EnableTheming

Gets or sets a value indicating whether themes apply to this control.

(Inherited from WebControl)
EnableViewState

Gets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client.

(Inherited from Control)
Events

Gets a list of event handler delegates for the control. This property is read-only.

(Inherited from Control)
Font

Gets the font properties associated with the Web server control.

(Inherited from WebControl)
FooterRow

Gets a GridViewRow object that represents the footer row in a GridView control.

FooterStyle

Gets a reference to the TableItemStyle object that enables you to set the appearance of the footer row in a GridView control.

ForeColor

Gets or sets the foreground color (typically the color of the text) of the Web server control.

(Inherited from WebControl)
GridLines

Gets or sets the gridline style for a GridView control.

HasAttributes

Gets a value indicating whether the control has attributes set.

(Inherited from WebControl)
HasChildViewState

Gets a value indicating whether the current server control's child controls have any saved view-state settings.

(Inherited from Control)
HeaderRow

Gets a GridViewRow object that represents the header row in a GridView control.

HeaderStyle

Gets a reference to the TableItemStyle object that enables you to set the appearance of the header row in a GridView control.

Height

Gets or sets the height of the Web server control.

(Inherited from WebControl)
HorizontalAlign

Gets or sets the horizontal alignment of a GridView control on the page.

ID

Gets or sets the programmatic identifier assigned to the server control.

(Inherited from Control)
IdSeparator

Gets the character used to separate control identifiers.

(Inherited from Control)
Initialized

Gets a value indicating whether the data-bound control has been initialized.

(Inherited from BaseDataBoundControl)
InsertMethod

Gets or sets the name of the method to call in order to insert data.

(Inherited from CompositeDataBoundControl)
IsBoundUsingDataSourceID

Gets a value indicating whether the DataSourceID property is set.

(Inherited from BaseDataBoundControl)
IsChildControlStateCleared

Gets a value indicating whether controls contained within this control have control state.

(Inherited from Control)
IsDataBindingAutomatic

Gets a value that indicates whether data binding is automatic.

(Inherited from BaseDataBoundControl)
IsEnabled

Gets a value indicating whether the control is enabled.

(Inherited from WebControl)
IsTrackingViewState

Gets a value that indicates whether the server control is saving changes to its view state.

(Inherited from Control)
IsUsingModelBinders

Gets a value that indicates whether model binding is in use.

(Inherited from CompositeDataBoundControl)
IsViewStateEnabled

Gets a value indicating whether view state is enabled for this control.

(Inherited from Control)
ItemType

Gets or sets the name of the data item type for strongly typed data binding.

(Inherited from DataBoundControl)
LoadViewStateByID

Gets a value indicating whether the control participates in loading its view state by ID instead of index.

(Inherited from Control)
NamingContainer

Gets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same ID property value.

(Inherited from Control)
Page

Gets a reference to the Page instance that contains the server control.

(Inherited from Control)
PageCount

Gets the number of pages required to display the records of the data source in a GridView control.

PageIndex

Gets or sets the index of the currently displayed page.

PagerSettings

Gets a reference to the PagerSettings object that enables you to set the properties of the pager buttons in a GridView control.

PagerStyle

Gets a reference to the TableItemStyle object that enables you to set the appearance of the pager row in a GridView control.

PagerTemplate

Gets or sets the custom content for the pager row in a GridView control.

PageSize

Gets or sets the number of records to display on a page in a GridView control.

Parent

Gets a reference to the server control's parent control in the page control hierarchy.

(Inherited from Control)
RenderingCompatibility

Gets a value that specifies the ASP.NET version that rendered HTML will be compatible with.

(Inherited from Control)
RequiresDataBinding

Gets or sets a value indicating whether the DataBind() method should be called.

(Inherited from BaseDataBoundControl)
RowHeaderColumn

Gets or sets the name of the column to use as the column header for the GridView control. This property is provided to make the control more accessible to users of assistive technology devices.

Rows

Gets a collection of GridViewRow objects that represent the data rows in a GridView control.

RowStyle

Gets a reference to the TableItemStyle object that enables you to set the appearance of the data rows in a GridView control.

SelectArguments

Gets a DataSourceSelectArguments object that the data-bound control uses when retrieving data from a data source control.

(Inherited from DataBoundControl)
SelectedDataKey

Gets the DataKey object that contains the data key value for the selected row in a GridView control.

SelectedIndex

Gets or sets the index of the selected row in a GridView control.

SelectedPersistedDataKey

Gets or sets the data-key value for the persisted selected item in a GridView control.

SelectedRow

Gets a reference to a GridViewRow object that represents the selected row in the control.

SelectedRowStyle

Gets a reference to the TableItemStyle object that enables you to set the appearance of the selected row in a GridView control.

SelectedValue

Gets the data key value of the selected row in a GridView control.

SelectMethod

The name of the method to call in order to read data.

(Inherited from DataBoundControl)
ShowFooter

Gets or sets a value indicating whether the footer row is displayed in a GridView control.

ShowHeader

Gets or sets a value indicating whether the header row is displayed in a GridView control.

ShowHeaderWhenEmpty

Gets or sets a value that indicates whether the heading of a column in the GridView control is visible when the column has no data.

Site

Gets information about the container that hosts the current control when rendered on a design surface.

(Inherited from Control)
SkinID

Gets or sets the skin to apply to the control.

(Inherited from WebControl)
SortDirection

Gets the sort direction of the column being sorted.

SortedAscendingCellStyle

Gets or sets the CSS style for a GridView column when the column is sorted in ascending order.

SortedAscendingHeaderStyle

Gets or sets the CSS style to apply to a GridView column heading when the column is sorted in ascending order.

SortedDescendingCellStyle

Gets or sets the style of a GridView column when the column is sorted in descending order.

SortedDescendingHeaderStyle

Gets or sets the style to apply to a GridView column heading when the column is sorted in descending order.

SortExpression

Gets the sort expression associated with the column or columns being sorted.

Style

Gets a collection of text attributes that will be rendered as a style attribute on the outer tag of the Web server control.

(Inherited from WebControl)
SupportsDisabledAttribute

Gets a value that indicates whether the control should set the disabled attribute of the rendered HTML element to "disabled" when the control's IsEnabled property is false.

(Inherited from BaseDataBoundControl)
TabIndex

Gets or sets the tab index of the Web server control.

(Inherited from WebControl)
TagKey

Gets the HtmlTextWriterTag value for the GridView control.

TagName

Gets the name of the control tag. This property is used primarily by control developers.

(Inherited from WebControl)
TemplateControl

Gets or sets a reference to the template that contains this control.

(Inherited from Control)
TemplateSourceDirectory

Gets the virtual directory of the Page or UserControl that contains the current server control.

(Inherited from Control)
ToolTip

Gets or sets the text displayed when the mouse pointer hovers over the Web server control.

(Inherited from WebControl)
TopPagerRow

Gets a GridViewRow object that represents the top pager row in a GridView control.

UniqueID

Gets the unique, hierarchically qualified identifier for the server control.

(Inherited from Control)
UpdateMethod

Gets or sets the name of the method to call in order to update data.

UpdateMethod

Gets or sets the name of the method to call in order to update data.

(Inherited from CompositeDataBoundControl)
UseAccessibleHeader

Gets or sets a value indicating whether a GridView control renders its header in an accessible format. This property is provided to make the control more accessible to users of assistive technology devices.

ValidateRequestMode

Gets or sets a value that indicates whether the control checks client input from the browser for potentially dangerous values.

(Inherited from Control)
ViewState

Gets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page.

(Inherited from Control)
ViewStateIgnoresCase

Gets a value that indicates whether the StateBag object is case-insensitive.

(Inherited from Control)
ViewStateMode

Gets or sets the view-state mode of this control.

(Inherited from Control)
VirtualItemCount

Gets or sets the virtual number of items in the data source that the GridView control is bound to when custom paging is used.

Visible

Gets or sets a value that indicates whether a server control is rendered as UI on the page.

(Inherited from Control)
Width

Gets or sets the width of the Web server control.

(Inherited from WebControl)

Methods

AddAttributesToRender(HtmlTextWriter)

Adds HTML attributes and styles that need to be rendered to the specified HtmlTextWriterTag. This method is used primarily by control developers.

(Inherited from WebControl)
AddedControl(Control, Int32)

Called after a child control is added to the Controls collection of the Control object.

(Inherited from Control)
AddParsedSubObject(Object)

Notifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's ControlCollection object.

(Inherited from Control)
ApplyStyle(Style)

Copies any nonblank elements of the specified style to the Web control, overwriting any existing style elements of the control. This method is primarily used by control developers.

(Inherited from WebControl)
ApplyStyleSheetSkin(Page)

Applies the style properties defined in the page style sheet to the control.

(Inherited from Control)
BeginRenderTracing(TextWriter, Object)

Begins design-time tracing of rendering data.

(Inherited from Control)
BuildProfileTree(String, Boolean)

Gathers information about the server control and delivers it to the Trace property to be displayed when tracing is enabled for the page.

(Inherited from Control)
ClearCachedClientID()

Sets the cached ClientID value to null.

(Inherited from Control)
ClearChildControlState()

Deletes the control-state information for the server control's child controls.

(Inherited from Control)
ClearChildState()

Deletes the view-state and control-state information for all the server control's child controls.

(Inherited from Control)
ClearChildViewState()

Deletes the view-state information for all the server control's child controls.

(Inherited from Control)
ClearEffectiveClientIDMode()

Sets the ClientIDMode property of the current control instance and of any child controls to Inherit.

(Inherited from Control)
ConfirmInitState()

Sets the initialized state of the data-bound control.

(Inherited from BaseDataBoundControl)
CopyBaseAttributes(WebControl)

Copies the properties not encapsulated by the Style object from the specified Web server control to the Web server control that this method is called from. This method is used primarily by control developers.

(Inherited from WebControl)
CreateAutoGeneratedColumn(AutoGeneratedFieldProperties)
Obsolete.

Creates an automatically generated column field.

CreateChildControls()

Creates the control hierarchy that is used to render a composite data-bound control based on the values that are stored in view state.

(Inherited from CompositeDataBoundControl)
CreateChildControls(IEnumerable, Boolean)

Creates the control hierarchy used to render the GridView control using the specified data source.

CreateChildTable()

Creates a new child table.

CreateColumns(PagedDataSource, Boolean)

Creates the set of column fields used to build the control hierarchy.

CreateControlCollection()

Creates a new ControlCollection object to hold the child controls (both literal and server) of the server control.

(Inherited from Control)
CreateControlStyle()

Creates the default style for the control.

CreateDataSourceSelectArguments()

Creates the DataSourceSelectArguments object that contains the arguments that get passed to the data source for processing.

CreateRow(Int32, Int32, DataControlRowType, DataControlRowState)

Creates a row in the GridView control.

DataBind()

Binds the data source to the GridView control. This method cannot be inherited.

DataBind(Boolean)

Binds a data source to the invoked server control and all its child controls with an option to raise the DataBinding event.

(Inherited from Control)
DataBindChildren()

Binds a data source to the server control's child controls.

(Inherited from Control)
DeleteRow(Int32)

Deletes the record at the specified index from the data source.

Dispose()

Enables a server control to perform final clean up before it is released from memory.

(Inherited from Control)
EndRenderTracing(TextWriter, Object)

Ends design-time tracing of rendering data.

(Inherited from Control)
EnsureChildControls()

Determines whether the server control contains child controls. If it does not, it creates child controls.

(Inherited from Control)
EnsureDataBound()

Calls the DataBind() method if the DataSourceID property is set and the data-bound control is marked to require binding.

(Inherited from BaseDataBoundControl)
EnsureID()

Creates an identifier for controls that do not have an identifier assigned.

(Inherited from Control)
Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
ExtractRowValues(IOrderedDictionary, GridViewRow, Boolean, Boolean)

Retrieves the values of each field declared within the specified row and stores them in the specified IOrderedDictionary object.

FindControl(String, Int32)

Searches the current naming container for a server control with the specified id and an integer, specified in the pathOffset parameter, which aids in the search. You should not override this version of the FindControl method.

(Inherited from Control)
FindControl(String)

Searches the current naming container for a server control with the specified id parameter.

(Inherited from Control)
Focus()

Sets input focus to a control.

(Inherited from Control)
GetCallbackResult()

Returns the result of a callback event that targets a control.

GetCallbackScript(IButtonControl, String)

Creates the callback script for a button that performs a sorting operation.

GetData()

Retrieves a DataSourceView object that the data-bound control uses to perform data operations.

(Inherited from DataBoundControl)
GetDataSource()

Retrieves the IDataSource interface that the data-bound control is associated with, if any.

(Inherited from DataBoundControl)
GetDesignModeState()

Gets design-time data for a control.

(Inherited from Control)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetRouteUrl(Object)

Gets the URL that corresponds to a set of route parameters.

(Inherited from Control)
GetRouteUrl(RouteValueDictionary)

Gets the URL that corresponds to a set of route parameters.

(Inherited from Control)
GetRouteUrl(String, Object)

Gets the URL that corresponds to a set of route parameters and a route name.

(Inherited from Control)
GetRouteUrl(String, RouteValueDictionary)

Gets the URL that corresponds to a set of route parameters and a route name.

(Inherited from Control)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetUniqueIDRelativeTo(Control)

Returns the prefixed portion of the UniqueID property of the specified control.

(Inherited from Control)
HasControls()

Determines if the server control contains any child controls.

(Inherited from Control)
HasEvents()

Returns a value indicating whether events are registered for the control or any child controls.

(Inherited from Control)
InitializePager(GridViewRow, Int32, PagedDataSource)

Initializes the pager row displayed when the paging feature is enabled.

InitializeRow(GridViewRow, DataControlField[])

Initializes a row in the GridView control.

IsBindableType(Type)

Determines whether the specified data type can be bound to a column in a GridView control.

IsLiteralContent()

Determines if the server control holds only literal content.

(Inherited from Control)
LoadControlState(Object)

Loads the state of the properties in the GridView control that need to be persisted, even when the EnableViewState property is set to false.

LoadViewState(Object)

Loads the previously saved view state of the GridView control.

MapPathSecure(String)

Retrieves the physical path that a virtual path, either absolute or relative, maps to.

(Inherited from Control)
MarkAsDataBound()

Sets the state of the control in view state as successfully bound to data.

(Inherited from DataBoundControl)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MergeStyle(Style)

Copies any nonblank elements of the specified style to the Web control, but will not overwrite any existing style elements of the control. This method is used primarily by control developers.

(Inherited from WebControl)
OnBubbleEvent(Object, EventArgs)

Determines whether the event for the Web server control is passed up the page's user interface (UI) server control hierarchy.

OnCreatingModelDataSource(CreatingModelDataSourceEventArgs)

Raises the CreatingModelDataSource event.

(Inherited from DataBoundControl)
OnDataBinding(EventArgs)

Raises the DataBinding event.

(Inherited from Control)
OnDataBound(EventArgs)

Raises the DataBound event.

(Inherited from BaseDataBoundControl)
OnDataPropertyChanged()

Rebinds the GridView control to its data after the DataMember, DataSource, or DataSourceID property is changed.

OnDataSourceViewChanged(Object, EventArgs)

Raises the DataSourceViewChanged event.

OnInit(EventArgs)

Raises the Init event.

OnLoad(EventArgs)

Handles the Load event.

(Inherited from DataBoundControl)
OnPageIndexChanged(EventArgs)

Raises the PageIndexChanged event.

OnPageIndexChanging(GridViewPageEventArgs)

Raises the PageIndexChanging event.

OnPagePreLoad(Object, EventArgs)

Sets the initialized state of the data-bound control before the control is loaded.

OnPreRender(EventArgs)

Raises the PreRender event.

OnRowCancelingEdit(GridViewCancelEditEventArgs)

Raises the RowCancelingEdit event.

OnRowCommand(GridViewCommandEventArgs)

Raises the RowCommand event.

OnRowCreated(GridViewRowEventArgs)

Raises the RowCreated event.

OnRowDataBound(GridViewRowEventArgs)

Raises the RowDataBound event.

OnRowDeleted(GridViewDeletedEventArgs)

Raises the RowDeleted event.

OnRowDeleting(GridViewDeleteEventArgs)

Raises the RowDeleting event.

OnRowEditing(GridViewEditEventArgs)

Raises the RowEditing event.

OnRowUpdated(GridViewUpdatedEventArgs)

Raises the RowUpdated event.

OnRowUpdating(GridViewUpdateEventArgs)

Raises the RowUpdating event.

OnSelectedIndexChanged(EventArgs)

Raises the SelectedIndexChanged event.

OnSelectedIndexChanging(GridViewSelectEventArgs)

Raises the SelectedIndexChanging event.

OnSorted(EventArgs)

Raises the Sorted event.

OnSorting(GridViewSortEventArgs)

Raises the Sorting event.

OnUnload(EventArgs)

Raises the Unload event.

(Inherited from Control)
OpenFile(String)

Gets a Stream used to read a file.

(Inherited from Control)
PerformDataBinding(IEnumerable)

Binds the specified data source to the GridView control.

PerformSelect()

Retrieves data from the associated data source.

(Inherited from DataBoundControl)
PrepareControlHierarchy()

Establishes the control hierarchy.

RaiseBubbleEvent(Object, EventArgs)

Assigns any sources of the event and its information to the control's parent.

(Inherited from Control)
RaiseCallbackEvent(String)

Creates the arguments for the callback handler in the GetCallbackEventReference(Control, String, String, String, Boolean) method.

RaisePostBackEvent(String)

Raises the appropriate events for the GridView control when it posts back to the server.

RemovedControl(Control)

Called after a child control is removed from the Controls collection of the Control object.

(Inherited from Control)
Render(HtmlTextWriter)

Renders the Web server control content to the client's browser using the specified HtmlTextWriter object.

RenderBeginTag(HtmlTextWriter)

Renders the HTML opening tag of the control to the specified writer. This method is used primarily by control developers.

(Inherited from WebControl)
RenderChildren(HtmlTextWriter)

Outputs the content of a server control's children to a provided HtmlTextWriter object, which writes the content to be rendered on the client.

(Inherited from Control)
RenderContents(HtmlTextWriter)

Renders the contents of the control to the specified writer. This method is used primarily by control developers.

(Inherited from WebControl)
RenderControl(HtmlTextWriter, ControlAdapter)

Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object.

(Inherited from Control)
RenderControl(HtmlTextWriter)

Outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled.

(Inherited from Control)
RenderEndTag(HtmlTextWriter)

Renders the HTML closing tag of the control into the specified writer. This method is used primarily by control developers.

(Inherited from WebControl)
ResolveAdapter()

Gets the control adapter responsible for rendering the specified control.

(Inherited from Control)
ResolveClientUrl(String)

Gets a URL that can be used by the browser.

(Inherited from Control)
ResolveUrl(String)

Converts a URL into one that is usable on the requesting client.

(Inherited from Control)
SaveControlState()

Saves the state of the properties in the GridView control that need to be persisted, even when the EnableViewState property is set to false.

SaveViewState()

Loads the previously saved view state of the GridView control.

SelectRow(Int32)

Selects the row to edit in a GridView control.

SetDesignModeState(IDictionary)

Sets design-time data for a control.

(Inherited from Control)
SetEditRow(Int32)

Puts a row in edit mode in a GridView control by using the specified row index.

SetPageIndex(Int32)

Sets the page index of the GridView control by using the row index.

SetRenderMethodDelegate(RenderMethod)

Assigns an event handler delegate to render the server control and its content into its parent control.

(Inherited from Control)
SetTraceData(Object, Object, Object)

Sets trace data for design-time tracing of rendering data, using the traced object, the trace data key, and the trace data value.

(Inherited from Control)
SetTraceData(Object, Object)

Sets trace data for design-time tracing of rendering data, using the trace data key and the trace data value.

(Inherited from Control)
Sort(String, SortDirection)

Sorts the GridView control based on the specified sort expression and direction.

ToString()

Returns a string that represents the current object.

(Inherited from Object)
TrackViewState()

Tracks view-state changes to the GridView control so they can be stored in the control's StateBag object. This object is accessible through the ViewState property.

UpdateRow(Int32, Boolean)

Updates the record at the specified row index using the field values of the row.

ValidateDataSource(Object)

Verifies that the object a data-bound control binds to is one it can work with.

(Inherited from DataBoundControl)

Events

CallingDataMethods

Occurs when data methods are being called.

(Inherited from DataBoundControl)
CreatingModelDataSource

Occurs when the ModelDataSource object is being created.

(Inherited from DataBoundControl)
DataBinding

Occurs when the server control binds to a data source.

(Inherited from Control)
DataBound

Occurs after the server control binds to a data source.

(Inherited from BaseDataBoundControl)
Disposed

Occurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested.

(Inherited from Control)
Init

Occurs when the server control is initialized, which is the first step in its lifecycle.

(Inherited from Control)
Load

Occurs when the server control is loaded into the Page object.

(Inherited from Control)
PageIndexChanged

Occurs when one of the pager buttons is clicked, but after the GridView control handles the paging operation.

PageIndexChanging

Occurs when one of the pager buttons is clicked, but before the GridView control handles the paging operation.

PreRender

Occurs after the Control object is loaded but prior to rendering.

(Inherited from Control)
RowCancelingEdit

Occurs when the Cancel button of a row in edit mode is clicked, but before the row exits edit mode.

RowCommand

Occurs when a button is clicked in a GridView control.

RowCreated

Occurs when a row is created in a GridView control.

RowDataBound

Occurs when a data row is bound to data in a GridView control.

RowDeleted

Occurs when a row's Delete button is clicked, but after the GridView control deletes the row.

RowDeleting

Occurs when a row's Delete button is clicked, but before the GridView control deletes the row.

RowEditing

Occurs when a row's Edit button is clicked, but before the GridView control enters edit mode.

RowUpdated

Occurs when a row's Update button is clicked, but after the GridView control updates the row.

RowUpdating

Occurs when a row's Update button is clicked, but before the GridView control updates the row.

SelectedIndexChanged

Occurs when a row's Select button is clicked, but after the GridView control handles the select operation.

SelectedIndexChanging

Occurs when a row's Select button is clicked, but before the GridView control handles the select operation.

Sorted

Occurs when the hyperlink to sort a column is clicked, but after the GridView control handles the sort operation.

Sorting

Occurs when the hyperlink to sort a column is clicked, but before the GridView control handles the sort operation.

Unload

Occurs when the server control is unloaded from memory.

(Inherited from Control)

Explicit Interface Implementations

IAttributeAccessor.GetAttribute(String)

Gets an attribute of the Web control with the specified name.

(Inherited from WebControl)
IAttributeAccessor.SetAttribute(String, String)

Sets an attribute of the Web control to the specified name and value.

(Inherited from WebControl)
ICallbackContainer.GetCallbackScript(IButtonControl, String)

Creates the callback script for a button that performs a sorting operation.

ICallbackEventHandler.GetCallbackResult()

Returns the result of a callback event that targets a control.

ICallbackEventHandler.RaiseCallbackEvent(String)

Creates the arguments for the callback handler in the GetCallbackEventReference(Control, String, String, String, Boolean) method.

IControlBuilderAccessor.ControlBuilder

For a description of this member, see ControlBuilder.

(Inherited from Control)
IControlDesignerAccessor.GetDesignModeState()

For a description of this member, see GetDesignModeState().

(Inherited from Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

For a description of this member, see SetDesignModeState(IDictionary).

(Inherited from Control)
IControlDesignerAccessor.SetOwnerControl(Control)

For a description of this member, see SetOwnerControl(Control).

(Inherited from Control)
IControlDesignerAccessor.UserData

For a description of this member, see UserData.

(Inherited from Control)
IDataBindingsAccessor.DataBindings

For a description of this member, see DataBindings.

(Inherited from Control)
IDataBindingsAccessor.HasDataBindings

For a description of this member, see HasDataBindings.

(Inherited from Control)
IDataBoundControl.DataKeyNames

Gets or sets the names of the primary key fields for the items displayed in a data-bound control.

IDataBoundControl.DataMember

Gets or sets the table that is exposed by the data source control to bind to the data-bound control.

IDataBoundControl.DataSource

Gets or sets the data source object from which the data-bound control retrieves the list of data items.

IDataBoundControl.DataSourceID

Gets or sets the ID of the data source from which the data-bound control retrieves the list of data items.

IDataBoundControl.DataSourceObject

Gets or sets the data source object from which the data-bound control retrieves the list of data items.

IDataBoundListControl.ClientIDRowSuffix

Gets or sets the names of the data fields whose values are appended to the ClientID property value to uniquely identify each instance of a data-bound control.

IDataBoundListControl.DataKeys

Gets a collection of objects that represent the DataKeys value in a data-bound control.

IDataBoundListControl.EnablePersistedSelection

Gets or sets a value that indicates whether the selection of a row is based on index or on data-key values.

IDataBoundListControl.SelectedDataKey

Gets the object that contains the data key value for the selected row in a data-bound control.

IDataBoundListControl.SelectedIndex

Gets or sets the index of the selected row in the data-bound control.

IDataKeysControl.ClientIDRowSuffixDataKeys

Gets the data values that are used to uniquely identify each instance of a data-bound control when ASP.NET generates the ClientID value.

IExpressionsAccessor.Expressions

For a description of this member, see Expressions.

(Inherited from Control)
IExpressionsAccessor.HasExpressions

For a description of this member, see HasExpressions.

(Inherited from Control)
IFieldControl.FieldsGenerator

Gets or sets the control that automatically generates the columns for a data-bound control for use by ASP.NET Dynamic Data.

IParserAccessor.AddParsedSubObject(Object)

For a description of this member, see AddParsedSubObject(Object).

(Inherited from Control)
IPersistedSelector.DataKey

For a description of this member, see DataKey.

IPostBackContainer.GetPostBackOptions(IButtonControl)

Creates a PostBackOptions object that represents the postback behavior of the specified button control.

IPostBackEventHandler.RaisePostBackEvent(String)

Raises the appropriate events for the GridView control when it posts back to the server.

Extension Methods

EnablePersistedSelection(BaseDataBoundControl)
Obsolete.

Enables selection to be persisted in data controls that support selection and paging.

FindDataSourceControl(Control)

Returns the data source that is associated with the data control for the specified control.

FindFieldTemplate(Control, String)

Returns the field template for the specified column in the specified control's naming container.

FindMetaTable(Control)

Returns the metatable object for the containing data control.

GetDefaultValues(INamingContainer)

Gets the collection of the default values for the specified data control.

GetMetaTable(INamingContainer)

Gets the table metadata for the specified data control.

SetMetaTable(INamingContainer, MetaTable, IDictionary<String,Object>)

Sets the table metadata and default value mapping for the specified data control.

SetMetaTable(INamingContainer, MetaTable, Object)

Sets the table metadata and default value mapping for the specified data control.

SetMetaTable(INamingContainer, MetaTable)

Sets the table metadata for the specified data control.

TryGetMetaTable(INamingContainer, MetaTable)

Determines whether table metadata is available.

EnableDynamicData(INamingContainer, Type, IDictionary<String,Object>)

Enables Dynamic Data behavior for the specified data control.

EnableDynamicData(INamingContainer, Type, Object)

Enables Dynamic Data behavior for the specified data control.

EnableDynamicData(INamingContainer, Type)

Enables Dynamic Data behavior for the specified data control.

Applies to

See also