From b812f10319b93791c9550a6b51d77ec2ddfb2e61 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 20 Jan 2025 18:26:29 -0800 Subject: [PATCH] code fence command names --- xml/System.Web.UI.WebControls/GridView.xml | 4622 ++++++++++---------- 1 file changed, 2310 insertions(+), 2312 deletions(-) diff --git a/xml/System.Web.UI.WebControls/GridView.xml b/xml/System.Web.UI.WebControls/GridView.xml index e00556e0c99..47b2bd1c825 100644 --- a/xml/System.Web.UI.WebControls/GridView.xml +++ b/xml/System.Web.UI.WebControls/GridView.xml @@ -76,510 +76,510 @@ Displays the values of a data source in a table where each column represents a field and each row represents a record. The control enables you to select, sort, and edit these items. - -## Introduction - The 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 control supports the following features: - -- Binding to data source controls, such as . - -- Built-in sort capabilities. - -- Built-in update and delete capabilities. - -- Built-in paging capabilities. - -- Built-in row selection capabilities. - -- Programmatic access to the 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](https://learn.microsoft.com/previous-versions/aspnet/ms228214(v=vs.100)). - + +## Introduction + The 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 control supports the following features: + +- Binding to data source controls, such as . + +- Built-in sort capabilities. + +- Built-in update and delete capabilities. + +- Built-in paging capabilities. + +- Built-in row selection capabilities. + +- Programmatic access to the 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](https://learn.microsoft.com/previous-versions/aspnet/ms228214(v=vs.100)). + > [!NOTE] -> If you are familiar with the control from the .NET Framework version 1.0, the control is the successor to the control. - - -## Column Fields - Each column in the control is represented by a object. By default, the property is set to `true`, which creates an 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 column fields appear in the control by setting the 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| -|-----------------------|-----------------| -||Displays the value of a field in a data source. This is the default column type of the control.| -||Displays a command button for each item in the control. This enables you to create a column of custom button controls, such as the Add or the Remove button.| -||Displays a check box for each item in the control. This column field type is commonly used to display fields with a Boolean value.| -||Displays predefined command buttons to perform select, edit, or delete operations.| -||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.| -||Displays an image for each item in the control.| -||Displays user-defined content for each item in the 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 `` tags between the opening and closing tags of the control. Next, list the column fields that you want to include between the opening and closing `` tags. The columns specified are added to the collection in the order listed. The collection stores all the column fields in the control and enables you to programmatically manage the column fields in the 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. - +> If you are familiar with the control from the .NET Framework version 1.0, the control is the successor to the control. + + +## Column Fields + Each column in the control is represented by a object. By default, the property is set to `true`, which creates an 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 column fields appear in the control by setting the 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| +|-----------------------|-----------------| +||Displays the value of a field in a data source. This is the default column type of the control.| +||Displays a command button for each item in the control. This enables you to create a column of custom button controls, such as the Add or the Remove button.| +||Displays a check box for each item in the control. This column field type is commonly used to display fields with a Boolean value.| +||Displays predefined command buttons to perform select, edit, or delete operations.| +||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.| +||Displays an image for each item in the control.| +||Displays user-defined content for each item in the 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 `` tags between the opening and closing tags of the control. Next, list the column fields that you want to include between the opening and closing `` tags. The columns specified are added to the collection in the order listed. The collection stores all the column fields in the control and enables you to programmatically manage the column fields in the 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 collection. - - -## Binding to Data - The control can be bound to a data source control (such as the control or control) or to any data source collection that implements the interface, such as , , , or other collection types. Use one of the following methods to bind the control to the appropriate data source type: - -- To bind to a data source control, set the property of the control to the value of the data source control. The 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 interface, programmatically set the property of the control to the data source and then call the method. When using this method, the 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](https://learn.microsoft.com/previous-versions/aspnet/6759sth4(v=vs.100)). - +> Automatically generated column fields are not added to the collection. + + +## Binding to Data + The control can be bound to a data source control (such as the control or control) or to any data source collection that implements the interface, such as , , , or other collection types. Use one of the following methods to bind the control to the appropriate data source type: + +- To bind to a data source control, set the property of the control to the value of the data source control. The 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 interface, programmatically set the property of the control to the data source and then call the method. When using this method, the 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](https://learn.microsoft.com/previous-versions/aspnet/6759sth4(v=vs.100)). + > [!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 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](https://learn.microsoft.com/previous-versions/dotnet/netframework-3.0/2e4hd649(v=vs.85)). - - -## Data Operations - The control provides many built-in capabilities that allow the user to sort, update, delete, select, and page through items in the control. When the control is bound to a data source control, the control can take advantage of the data source control's capabilities and provide automatic sort, update, and delete functionality. - +> 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 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](https://learn.microsoft.com/previous-versions/dotnet/netframework-3.0/2e4hd649(v=vs.85)). + + +## Data Operations + The control provides many built-in capabilities that allow the user to sort, update, delete, select, and page through items in the control. When the control is bound to a data source control, the control can take advantage of the data source control's capabilities and provide automatic sort, update, and delete functionality. + > [!NOTE] -> The 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 control with respect to a specific column by clicking on the column's header. To enable sorting, set the property to `true`. - - The automatic updating, deleting, and selection functionalities are enabled when a button in a or column field, with a command name of "Edit", "Delete", and "Select", respectively, is clicked. The control can automatically add a column field with an Edit, Delete, or Select button if the , , or property is set to `true`, respectively. - +> The 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 control with respect to a specific column by clicking on the column's header. To enable sorting, set the property to `true`. + + The automatic updating, deleting, and selection functionalities are enabled when a button in a or column field, with a command name of "Edit", "Delete", and "Select", respectively, is clicked. The control can automatically add a column field with an Edit, Delete, or Select button if the , , or property is set to `true`, respectively. + > [!NOTE] -> Inserting records into the data source is not directly supported by the control. However, it is possible to insert records by using the control in conjunction with the `DetailsView` or `FormView` control. For more information, see or , respectively. - - Instead of displaying all the records in the data source at the same time, the control can automatically break the records up into pages. To enable paging, set the property to `true`. - +> Inserting records into the data source is not directly supported by the control. However, it is possible to insert records by using the control in conjunction with the `DetailsView` or `FormView` control. For more information, see or , respectively. + + Instead of displaying all the records in the data source at the same time, the control can automatically break the records up into pages. To enable paging, set the property to `true`. + > [!NOTE] -> The control is re-created on postback based on the information that is stored in . If the control includes a or a with the property set to `true`, then the 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 control by setting the style properties for the different parts of the control. The following table lists the different style properties. - -|Style property|Description| -|--------------------|-----------------| -||The style settings for the alternating data rows in the control. When this property is set, the data rows are displayed alternating between the settings and the settings.| -||The style settings for the row being edited in the control.| -||The style settings for the empty data row displayed in the control when the data source does not contain any records.| -||The style settings for the footer row of the control.| -||The style settings for the header row of the control.| -||The style settings for the pager row of the control.| -||The style settings for the data rows in the control. When the property is also set, the data rows are displayed alternating between the settings and the settings.| -||The style settings for the selected row in the control.| -||The style setting for the data column the data is sorted by in the control. When this style is set, the style (for example, highlighted column) is applied to cells when the data is sorted in ascending order.| -||The style setting for the data column the data is sorted by in the control. When this style is set, an arrow indicating the data is sorted ascending is placed on the header of the control when the data is sorted in ascending order.| -||The style setting for the data column the data is sorted by in the control. When this style is set, the style (for example, highlighted column) is applied to cells when the data is sorted in descending order.| -||The style setting for the data column the data is sorted by in the control. When this style is set, an arrow pointing down is placed on the header of the 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| -|--------------|-----------------| -||Shows or hides the footer section of the control.| -||Shows or hides the header section of the control.| - - -## Events - The 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 control. - -|Event|Description| -|-----------|-----------------| -||Occurs when one of the pager buttons is clicked, but after the 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.| -||Occurs when one of the pager buttons is clicked, but before the control handles the paging operation. This event is often used to cancel the paging operation.| -||Occurs when a row's Cancel button is clicked, but before the control exits edit mode. This event is often used to stop the canceling operation.| -||Occurs when a button is clicked in the control. This event is often used to perform a task when a button is clicked in the control.| -||Occurs when a new row is created in the control. This event is often used to modify the contents of a row when the row is created.| -||Occurs when a data row is bound to data in the control. This event is often used to modify the contents of a row when the row is bound to data.| -||Occurs when a row's Delete button is clicked, but after the control deletes the record from the data source. This event is often used to check the results of the delete operation.| -||Occurs when a row's Delete button is clicked, but before the control deletes the record from the data source. This event is often used to cancel the deleting operation.| -||Occurs when a row's Edit button is clicked, but before the control enters edit mode. This event is often used to cancel the editing operation.| -||Occurs when a row's Update button is clicked, but after the control updates the row. This event is often used to check the results of the update operation.| -||Occurs when a row's Update button is clicked, but before the control updates the row. This event is often used to cancel the updating operation.| -||Occurs when a row's Select button is clicked, but after the control handles the select operation. This event is often used to perform a task after a row is selected in the control.| -||Occurs when a row's Select button is clicked, but before the control handles the select operation. This event is often used to cancel the selection operation.| -||Occurs when the hyperlink to sort a column is clicked, but after the control handles the sort operation. This event is commonly used to perform a task after the user clicks a hyperlink to sort a column.| -||Occurs when the hyperlink to sort a column is clicked, but before the 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](https://learn.microsoft.com/previous-versions/ms228004(v=vs.140)) and [ASP.NET Controls and Accessibility](https://learn.microsoft.com/previous-versions/ms227996(v=vs.140)). - - -## Declarative Syntax - -``` - -         -         -                 -                         -                         -                         -                         -                 -                 -                         -                         -                         -                         -                 -                 -                         -                         -                         -                         -                 -                 -                         -                         -                         -                         -                 -                 -                         -                         -                         -                         -                 -                 -                         -                         -                         -                         -                 -                 -                         -                         -                         -                         -                 -                 -                             -                             -                             -                             -                         - -                         -                         - -                         -                         - -                         -                         - -                         -                         - -                         -                         - -                         -                 -         -         -         -         - -         -         -         -         -         -         - -         -         -         - -``` - - - -## Examples - A Visual Studio Web site project with source code is available to accompany this topic: [Download](https://go.microsoft.com/fwlink/?LinkId=191882). - - The following example demonstrates how use the control to display the values from the Customers table of the AdventureWorksLT sample database in Microsoft SQL Server. The values are retrieved using a control. - +> The control is re-created on postback based on the information that is stored in . If the control includes a or a with the property set to `true`, then the 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 control by setting the style properties for the different parts of the control. The following table lists the different style properties. + +|Style property|Description| +|--------------------|-----------------| +||The style settings for the alternating data rows in the control. When this property is set, the data rows are displayed alternating between the settings and the settings.| +||The style settings for the row being edited in the control.| +||The style settings for the empty data row displayed in the control when the data source does not contain any records.| +||The style settings for the footer row of the control.| +||The style settings for the header row of the control.| +||The style settings for the pager row of the control.| +||The style settings for the data rows in the control. When the property is also set, the data rows are displayed alternating between the settings and the settings.| +||The style settings for the selected row in the control.| +||The style setting for the data column the data is sorted by in the control. When this style is set, the style (for example, highlighted column) is applied to cells when the data is sorted in ascending order.| +||The style setting for the data column the data is sorted by in the control. When this style is set, an arrow indicating the data is sorted ascending is placed on the header of the control when the data is sorted in ascending order.| +||The style setting for the data column the data is sorted by in the control. When this style is set, the style (for example, highlighted column) is applied to cells when the data is sorted in descending order.| +||The style setting for the data column the data is sorted by in the control. When this style is set, an arrow pointing down is placed on the header of the 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| +|--------------|-----------------| +||Shows or hides the footer section of the control.| +||Shows or hides the header section of the control.| + + +## Events + The 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 control. + +|Event|Description| +|-----------|-----------------| +||Occurs when one of the pager buttons is clicked, but after the 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.| +||Occurs when one of the pager buttons is clicked, but before the control handles the paging operation. This event is often used to cancel the paging operation.| +||Occurs when a row's Cancel button is clicked, but before the control exits edit mode. This event is often used to stop the canceling operation.| +||Occurs when a button is clicked in the control. This event is often used to perform a task when a button is clicked in the control.| +||Occurs when a new row is created in the control. This event is often used to modify the contents of a row when the row is created.| +||Occurs when a data row is bound to data in the control. This event is often used to modify the contents of a row when the row is bound to data.| +||Occurs when a row's Delete button is clicked, but after the control deletes the record from the data source. This event is often used to check the results of the delete operation.| +||Occurs when a row's Delete button is clicked, but before the control deletes the record from the data source. This event is often used to cancel the deleting operation.| +||Occurs when a row's Edit button is clicked, but before the control enters edit mode. This event is often used to cancel the editing operation.| +||Occurs when a row's Update button is clicked, but after the control updates the row. This event is often used to check the results of the update operation.| +||Occurs when a row's Update button is clicked, but before the control updates the row. This event is often used to cancel the updating operation.| +||Occurs when a row's Select button is clicked, but after the control handles the select operation. This event is often used to perform a task after a row is selected in the control.| +||Occurs when a row's Select button is clicked, but before the control handles the select operation. This event is often used to cancel the selection operation.| +||Occurs when the hyperlink to sort a column is clicked, but after the control handles the sort operation. This event is commonly used to perform a task after the user clicks a hyperlink to sort a column.| +||Occurs when the hyperlink to sort a column is clicked, but before the 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](https://learn.microsoft.com/previous-versions/ms228004(v=vs.140)) and [ASP.NET Controls and Accessibility](https://learn.microsoft.com/previous-versions/ms227996(v=vs.140)). + + +## Declarative Syntax + +``` + +         +         +                 +                         +                         +                         +                         +                 +                 +                         +                         +                         +                         +                 +                 +                         +                         +                         +                         +                 +                 +                         +                         +                         +                         +                 +                 +                         +                         +                         +                         +                 +                 +                         +                         +                         +                         +                 +                 +                         +                         +                         +                         +                 +                 +                             +                             +                             +                             +                         + +                         +                         + +                         +                         + +                         +                         + +                         +                         + +                         +                         + +                         +                 +         +         +         +         + +         +         +         +         +         +         + +         +         +         + +``` + + + +## Examples + A Visual Studio Web site project with source code is available to accompany this topic: [Download](https://go.microsoft.com/fwlink/?LinkId=191882). + + The following example demonstrates how use the control to display the values from the Customers table of the AdventureWorksLT sample database in Microsoft SQL Server. The values are retrieved using a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSimple/CS/displaycustomers.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSimple/VB/displaycustomers.aspx" id="Snippet1"::: - - The following example demonstrates how to use the control and a control so that you can edit records. - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSimple/VB/displaycustomers.aspx" id="Snippet1"::: + + The following example demonstrates how to use the control and a control so that you can edit records. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewEdit/CS/editorders.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewEdit/VB/editorders.aspx" id="Snippet1"::: - - For an example demonstrating how to access values in cells, see . - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewEdit/VB/editorders.aspx" id="Snippet1"::: + + For an example demonstrating how to access values in cells, see . + ]]> @@ -619,19 +619,19 @@ Initializes a new instance of the class. - class. To dynamically add a control to a page, create a new object, set its properties, and then add it to the collection of a container control, such as . - - - -## Examples - The following example demonstrates how to use the constructor to dynamically add a control to a page. - + class. To dynamically add a control to a page, create a new object, set its properties, and then add it to the collection of a container control, such as . + + + +## Examples + The following example demonstrates how to use the constructor to dynamically add a control to a page. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewCtor/CS/gridviewctorcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewCtor/VB/gridviewctorvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewCtor/VB/gridviewctorvb.aspx" id="Snippet1"::: + ]]> @@ -664,13 +664,13 @@ if custom paging is enabled; otherwise, . The default is . - control in chunks. The number of items on a page is determined by the property. Normally, every row in the data source is read every time the control moves to a different page. This can consume a lot of resources when the total number of items in the data source is very large. Custom paging allows you to read just the items you need for a single page from the data source. - - To enable custom paging, set both the and properties to `true`. In a handler for the event, set the property to the new page index value, set the property to the total number of items in the data source, set the data source to return only the rows needed for the current page, and call the method. The property enables the control to determine the total number of pages; this value is normally determined automatically by reading all of the items. - + control in chunks. The number of items on a page is determined by the property. Normally, every row in the data source is read every time the control moves to a different page. This can consume a lot of resources when the total number of items in the data source is very large. Custom paging allows you to read just the items you need for a single page from the data source. + + To enable custom paging, set both the and properties to `true`. In a handler for the event, set the property to the new page index value, set the property to the total number of items in the data source, set the data source to return only the rows needed for the current page, and call the method. The property enables the control to determine the total number of pages; this value is normally determined automatically by reading all of the items. + ]]> @@ -702,44 +702,44 @@ if the paging feature is enabled; otherwise, . The default is . - control can automatically break the records up into pages. If the data source supports the paging capability, the control can take advantage of that and provide built-in paging functionality. The paging feature can be used with any data source object that supports the interface or a data source that supports paging capability. - - To enable the paging feature, set the property to `true`. By default, the control displays 10 records on a page at a time. You can change the number of records displayed on a page by setting the property. To determine the total number of pages required to display the data source contents, use the property. You can determine the index of the currently displayed page by using the property. - - When paging is enabled, an additional row called the pager row is automatically displayed in the control. The pager row contains controls that allow the user to navigate to the other pages. You can control the settings of the pager row (such as the pager display mode, the number of page links to display at a time, and the pager control's text labels) by using the property. The pager row can be displayed at the top, bottom, or both the top and bottom of the control by setting the property. You can also select from one of four built-in pager display modes by setting the property. The following table describes the built-in display modes. - -|Mode|Description| -|----------|-----------------| -|`PagerButton.NextPrevious`|A set of pagination controls consisting of previous and next buttons.| -|`PagerButton.NextPreviousFirstLast`|A set of pagination controls consisting of previous, next, first, and last buttons.| -|`PagerButton.Numeric`|A set of pagination controls consisting of numbered link buttons to access pages directly. This is the default mode.| -|`PagerButton.NumericFirstLast`|A set of pagination controls consisting of numbered and first and last link buttons.| - - To control the appearance of the pager row (including its background color, font color, and position), use the property. - + control can automatically break the records up into pages. If the data source supports the paging capability, the control can take advantage of that and provide built-in paging functionality. The paging feature can be used with any data source object that supports the interface or a data source that supports paging capability. + + To enable the paging feature, set the property to `true`. By default, the control displays 10 records on a page at a time. You can change the number of records displayed on a page by setting the property. To determine the total number of pages required to display the data source contents, use the property. You can determine the index of the currently displayed page by using the property. + + When paging is enabled, an additional row called the pager row is automatically displayed in the control. The pager row contains controls that allow the user to navigate to the other pages. You can control the settings of the pager row (such as the pager display mode, the number of page links to display at a time, and the pager control's text labels) by using the property. The pager row can be displayed at the top, bottom, or both the top and bottom of the control by setting the property. You can also select from one of four built-in pager display modes by setting the property. The following table describes the built-in display modes. + +|Mode|Description| +|----------|-----------------| +|`PagerButton.NextPrevious`|A set of pagination controls consisting of previous and next buttons.| +|`PagerButton.NextPreviousFirstLast`|A set of pagination controls consisting of previous, next, first, and last buttons.| +|`PagerButton.Numeric`|A set of pagination controls consisting of numbered link buttons to access pages directly. This is the default mode.| +|`PagerButton.NumericFirstLast`|A set of pagination controls consisting of numbered and first and last link buttons.| + + To control the appearance of the pager row (including its background color, font color, and position), use the property. + > [!NOTE] -> The control automatically hides the pager row when the data source contains only one page of records. - - The control also enables you to define a custom template for the pager row. For more information about creating a custom pager row template, see . - - The control provides several events that you can use to perform a custom action when paging occurs. The following table lists the available events. - -|Event|Description| -|-----------|-----------------| -||Occurs when one of the pager buttons is clicked, but after the 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.| -||Occurs when one of the pager buttons is clicked, but before the control handles the paging operation. This event is often used to cancel the paging operation.| - - - -## Examples - The following example demonstrates how to use the property to declaratively enable the paging feature in the control. - +> The control automatically hides the pager row when the data source contains only one page of records. + + The control also enables you to define a custom template for the pager row. For more information about creating a custom pager row template, see . + + The control provides several events that you can use to perform a custom action when paging occurs. The following table lists the available events. + +|Event|Description| +|-----------|-----------------| +||Occurs when one of the pager buttons is clicked, but after the 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.| +||Occurs when one of the pager buttons is clicked, but before the control handles the paging operation. This event is often used to cancel the paging operation.| + + + +## Examples + The following example demonstrates how to use the property to declaratively enable the paging feature in the control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewAllowPaging/CS/gridviewallowpagingcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowPaging/VB/gridviewallowpagingvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowPaging/VB/gridviewallowpagingvb.aspx" id="Snippet1"::: + ]]> @@ -781,41 +781,41 @@ if the sorting feature is enabled; otherwise, . The default is . - control, the control can take advantage of the data source control's capabilities and provide automatic sorting functionality. When the control is bound to a data source by setting the property programmatically, you must provide the sorting functionality by using the event. - + control, the control can take advantage of the data source control's capabilities and provide automatic sorting functionality. When the control is bound to a data source by setting the property programmatically, you must provide the sorting functionality by using the event. + > [!NOTE] -> Different data sources have different requirements for enabling their sorting capabilities. To determine the requirements, see the documentation for the specific data source. - - To enable sorting, set the property to `true`. When sorting is enabled, the heading text for each column field with its property set is displayed as a link button. - +> Different data sources have different requirements for enabling their sorting capabilities. To determine the requirements, see the documentation for the specific data source. + + To enable sorting, set the property to `true`. When sorting is enabled, the heading text for each column field with its property set is displayed as a link button. + > [!NOTE] -> The property for an automatically generated columns field is automatically populated. If you define your own columns through the collection, you must set the property for each column; otherwise, the column will not display the link button in the header. - - Clicking the link button for a column causes the items in the control to be sorted based on the sort expression. Typically, the sort expression is simply the name of the field displayed in the column, which causes the control to sort with respect to that column. To sort by multiple fields, use a sort expression that contains a comma-separated list of field names. You can determine the sort expression that the control is applying by using the property. Clicking a column's link button repeatedly toggles the sort direction between ascending and descending order. To determine the current sort direction, use the property. - - The control provides several events that you can use to perform a custom action when sorting occurs. The following table lists the available events. - -|Event|Description| -|-----------|-----------------| -||Occurs when the hyperlink to sort a column is clicked, but after the control handles the sort operation. This event is commonly used to perform a task after the user clicks a hyperlink to sort a column.| -||Occurs when the hyperlink to sort a column is clicked, but before the control handles the sort operation. This event is often used to cancel the sorting operation or to perform a custom sorting routine.| - - - -## Examples - The following example demonstrates how to use the property to enable sorting in a control when automatically generated columns are used. - +> The property for an automatically generated columns field is automatically populated. If you define your own columns through the collection, you must set the property for each column; otherwise, the column will not display the link button in the header. + + Clicking the link button for a column causes the items in the control to be sorted based on the sort expression. Typically, the sort expression is simply the name of the field displayed in the column, which causes the control to sort with respect to that column. To sort by multiple fields, use a sort expression that contains a comma-separated list of field names. You can determine the sort expression that the control is applying by using the property. Clicking a column's link button repeatedly toggles the sort direction between ascending and descending order. To determine the current sort direction, use the property. + + The control provides several events that you can use to perform a custom action when sorting occurs. The following table lists the available events. + +|Event|Description| +|-----------|-----------------| +||Occurs when the hyperlink to sort a column is clicked, but after the control handles the sort operation. This event is commonly used to perform a task after the user clicks a hyperlink to sort a column.| +||Occurs when the hyperlink to sort a column is clicked, but before the control handles the sort operation. This event is often used to cancel the sorting operation or to perform a custom sorting routine.| + + + +## Examples + The following example demonstrates how to use the property to enable sorting in a control when automatically generated columns are used. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewAllowSorting/CS/gridviewallowsortingcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowSorting/VB/gridviewallowsortingvb.aspx" id="Snippet1"::: - - The following example demonstrates how to use the property to enable sorting in a control when a collection is defined. An image is also programmatically added to the header of the column being sorted to indicate the sort direction. You must provide your own images for this sample to work. - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowSorting/VB/gridviewallowsortingvb.aspx" id="Snippet1"::: + + The following example demonstrates how to use the property to enable sorting in a control when a collection is defined. An image is also programmatically added to the header of the column being sorted to indicate the sort direction. You must provide your own images for this sample to work. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewAllowSortingColumns/CS/GridViewAllowSortingColumnscs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowSortingColumns/VB/GridViewAllowSortingColumnsvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowSortingColumns/VB/GridViewAllowSortingColumnsvb.aspx" id="Snippet1"::: + ]]> @@ -862,25 +862,25 @@ Gets a reference to the object that enables you to set the appearance of alternating data rows in a control. A reference to the that represents the style of alternating data rows in a control. - property to control the appearance of alternating data rows in a control. When this property is set, the data rows are displayed alternating between the settings and the settings. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: - -- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `AlternatingRowStyle-ForeColor`). - -- Nest an `` element between the opening and closing tags of the control. - - The properties can also be set programmatically in the form `Property.Subproperty` (for example, `AlternatingRowStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. - - - -## Examples - The following example demonstrates how to use the property to declaratively define the style for alternating data rows in a control. - + property to control the appearance of alternating data rows in a control. When this property is set, the data rows are displayed alternating between the settings and the settings. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: + +- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `AlternatingRowStyle-ForeColor`). + +- Nest an `` element between the opening and closing tags of the control. + + The properties can also be set programmatically in the form `Property.Subproperty` (for example, `AlternatingRowStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. + + + +## Examples + The following example demonstrates how to use the property to declaratively define the style for alternating data rows in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowStyle/CS/gridviewrowstylecs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowStyle/VB/gridviewrowstylevb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowStyle/VB/gridviewrowstylevb.aspx" id="Snippet1"::: + ]]> @@ -920,33 +920,33 @@ to automatically create bound fields for each field in the data source; otherwise, . The default is . - property is set to `true`, an object is automatically created for each field in the data source. Each field is then displayed as a column in the control in the order that the fields appear in the data source. This option provides a convenient way to display every field in the data source; however, you have limited control of how an automatically generated column field is displayed or behaves. - - Instead of letting the control automatically generate the column fields, you can manually define the column fields by setting the property to `false` and then creating a custom `Columns` collection. In addition to bound column fields, you can also display a button column field, a check box column field, a command field, a hyperlink column field, an image field, or a column field based on your own custom-defined template. - - You can also combine explicitly declared column fields with automatically generated column fields. When both are used, explicitly declared column fields are rendered first, followed by the automatically generated column fields. Automatically generated bound column fields are not added to the collection. For more information, see . - - If you set this property to `true` and set the property to a model type, controls are generated. If you do not set the property, controls are generated. If you do not want controls, you have the following options: - -- Set the property to `null` in the `Page_Load` event handler. In that case, controls are generated. - -- Write custom code to automatically generate fields by creating and assigning your own class and assigning an instance of it to the control. - -- Set to `false`. In that case, no fields are generated, and you must manually specify fields using controls such as or . - -- Do not set the property. In that case, controls are generated. - - - -## Examples - The following example demonstrates how to use the property to automatically create bound field columns in a control for each field in the data source. - + property is set to `true`, an object is automatically created for each field in the data source. Each field is then displayed as a column in the control in the order that the fields appear in the data source. This option provides a convenient way to display every field in the data source; however, you have limited control of how an automatically generated column field is displayed or behaves. + + Instead of letting the control automatically generate the column fields, you can manually define the column fields by setting the property to `false` and then creating a custom `Columns` collection. In addition to bound column fields, you can also display a button column field, a check box column field, a command field, a hyperlink column field, an image field, or a column field based on your own custom-defined template. + + You can also combine explicitly declared column fields with automatically generated column fields. When both are used, explicitly declared column fields are rendered first, followed by the automatically generated column fields. Automatically generated bound column fields are not added to the collection. For more information, see . + + If you set this property to `true` and set the property to a model type, controls are generated. If you do not set the property, controls are generated. If you do not want controls, you have the following options: + +- Set the property to `null` in the `Page_Load` event handler. In that case, controls are generated. + +- Write custom code to automatically generate fields by creating and assigning your own class and assigning an instance of it to the control. + +- Set to `false`. In that case, no fields are generated, and you must manually specify fields using controls such as or . + +- Do not set the property. In that case, controls are generated. + + + +## Examples + The following example demonstrates how to use the property to automatically create bound field columns in a control for each field in the data source. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSimple/CS/displaycustomers.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSimple/VB/displaycustomers.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSimple/VB/displaycustomers.aspx" id="Snippet1"::: + ]]> @@ -982,34 +982,34 @@ to automatically add a field column with a Delete button for each data row; otherwise, . The default is . - control, the control can take advantage of the data source control's capabilities and provide automatic deleting functionality. - + control, the control can take advantage of the data source control's capabilities and provide automatic deleting functionality. + > [!NOTE] -> For a data source control to delete data, it must be configured to delete data. To configure a data source control to delete records, see the documentation for the specific data source control. - - When the property is set to `true`, a column (represented by a object) with a Delete button for each data row is automatically added to the control. Clicking the Delete button for a row permanently removes that record from the data source. - +> For a data source control to delete data, it must be configured to delete data. To configure a data source control to delete records, see the documentation for the specific data source control. + + When the property is set to `true`, a column (represented by a object) with a Delete button for each data row is automatically added to the control. Clicking the Delete button for a row permanently removes that record from the data source. + > [!NOTE] -> You must also set the property to identify the key field or fields of the data source for the automatic deleting feature to work. - - The control provides several events that you can use to perform a custom action when a row is deleted. The following table lists the available events. - -|Event|Description| -|-----------|-----------------| -||Occurs when a row's Delete button is clicked, but after the control deletes the record from the data source. This event is often used to check the results of the delete operation.| -||Occurs when a row's Delete button is clicked, but before the control deletes the record from the data source. This event is often used to cancel the deleting operation.| - - - -## Examples - The following example demonstrates how to use the property to enable the automatic deleting feature of a control. - +> You must also set the property to identify the key field or fields of the data source for the automatic deleting feature to work. + + The control provides several events that you can use to perform a custom action when a row is deleted. The following table lists the available events. + +|Event|Description| +|-----------|-----------------| +||Occurs when a row's Delete button is clicked, but after the control deletes the record from the data source. This event is often used to check the results of the delete operation.| +||Occurs when a row's Delete button is clicked, but before the control deletes the record from the data source. This event is often used to cancel the deleting operation.| + + + +## Examples + The following example demonstrates how to use the property to enable the automatic deleting feature of a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewEdit/CS/editorders.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewEdit/VB/editorders.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewEdit/VB/editorders.aspx" id="Snippet1"::: + ]]> @@ -1046,42 +1046,42 @@ to automatically add a field column with an Edit button for each data row; otherwise, . The default is . - control, the control can take advantage of the data source control's capabilities and provide automatic updating functionality. - + control, the control can take advantage of the data source control's capabilities and provide automatic updating functionality. + > [!NOTE] -> For a data source control to update data, it must be configured to update data. To configure a data source control to update records, see the documentation for the specific data source control. - - When the property is set to `true`, a column (represented by a object) with an Edit button for each data row is automatically added to the control. Clicking an Edit button for a row puts that row in edit mode. When a row is in edit mode, each column field in the row that is not read-only displays the appropriate input control, such as a control, for the field's data type. This allows the user to modify the field's value. - - When clicked, the Edit button is also replaced with an Update button and a Cancel button. Clicking the Update button updates the row in the data source with any value changes and returns the row to display mode. Clicking the Cancel button abandons any value changes and returns the row to display mode. - +> For a data source control to update data, it must be configured to update data. To configure a data source control to update records, see the documentation for the specific data source control. + + When the property is set to `true`, a column (represented by a object) with an Edit button for each data row is automatically added to the control. Clicking an Edit button for a row puts that row in edit mode. When a row is in edit mode, each column field in the row that is not read-only displays the appropriate input control, such as a control, for the field's data type. This allows the user to modify the field's value. + + When clicked, the Edit button is also replaced with an Update button and a Cancel button. Clicking the Update button updates the row in the data source with any value changes and returns the row to display mode. Clicking the Cancel button abandons any value changes and returns the row to display mode. + > [!NOTE] -> You can programmatically put a row in edit mode by setting the property with the index of the row. To programmatically exit edit mode, set the property to -1. - - When using the built-in updating functionality, you must set the property with a comma-separated list of field names to identify the primary key field or fields of the data source; otherwise, the built-in updating functionality will not be able to update the correct record. When using automatically generated field columns (by setting the property to `true`), the control automatically ensures that the automatically generated field columns that correspond to the field or fields specified in the property are read-only. - - You can control the appearance of a row that is in edit mode by using the property. Common settings usually include a custom background color, foreground color, and font properties. - - The control provides several events that you can use to perform a custom action when a row is updated. The following table lists the available events. - -|Event|Description| -|-----------|-----------------| -||Occurs when a row's Cancel button is clicked, but before the control cancels out of edit mode. This event is often used to stop the canceling operation.| -||Occurs when a row's Edit button is clicked, but before the control enters edit mode. This event is often used to cancel the editing operation.| -||Occurs when a row's Update button is clicked, but after the control updates the row. This event is often used to check the results of the update operation.| -||Occurs when a row's Update button is clicked, but before the control updates the row. This event is often used to cancel the updating operation.| - - - -## Examples - The following example demonstrates how to use the property to enable the automatic editing feature of the control. - +> You can programmatically put a row in edit mode by setting the property with the index of the row. To programmatically exit edit mode, set the property to -1. + + When using the built-in updating functionality, you must set the property with a comma-separated list of field names to identify the primary key field or fields of the data source; otherwise, the built-in updating functionality will not be able to update the correct record. When using automatically generated field columns (by setting the property to `true`), the control automatically ensures that the automatically generated field columns that correspond to the field or fields specified in the property are read-only. + + You can control the appearance of a row that is in edit mode by using the property. Common settings usually include a custom background color, foreground color, and font properties. + + The control provides several events that you can use to perform a custom action when a row is updated. The following table lists the available events. + +|Event|Description| +|-----------|-----------------| +||Occurs when a row's Cancel button is clicked, but before the control cancels out of edit mode. This event is often used to stop the canceling operation.| +||Occurs when a row's Edit button is clicked, but before the control enters edit mode. This event is often used to cancel the editing operation.| +||Occurs when a row's Update button is clicked, but after the control updates the row. This event is often used to check the results of the update operation.| +||Occurs when a row's Update button is clicked, but before the control updates the row. This event is often used to cancel the updating operation.| + + + +## Examples + The following example demonstrates how to use the property to enable the automatic editing feature of the control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewEdit/CS/editorders.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewEdit/VB/editorders.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewEdit/VB/editorders.aspx" id="Snippet1"::: + ]]> @@ -1125,31 +1125,31 @@ to automatically add a field column with a Select button for each data row; otherwise, . The default is . - property is set to `true`, a column (represented by a object) with a Select button for each data row is automatically added to the control. Clicking the Select button for a row selects that row in the control, which sets the property to the index of the row. To retrieve the object that represents the selected row, use the property. You can also get the primary key value for the selected record by using the property. The property contains the values of the key fields specified in the property. - + property is set to `true`, a column (represented by a object) with a Select button for each data row is automatically added to the control. Clicking the Select button for a row selects that row in the control, which sets the property to the index of the row. To retrieve the object that represents the selected row, use the property. You can also get the primary key value for the selected record by using the property. The property contains the values of the key fields specified in the property. + > [!NOTE] -> You can programmatically select a row by setting the property. To cancel the selection of a row, set the property to -1. - - You can control the appearance of the selected row by using the property. Common settings usually include a custom background color, foreground color, and font properties. - - The control provides several events that you can use to perform a custom action when a row is selected. The following table lists the available events. - -|Event|Description| -|-----------|-----------------| -||Occurs when a row's Select button is clicked, but after the control handles the select operation. This event is often used to perform a task after a row is selected in the control.| -||Occurs when a row's Select button is clicked, but before the control handles the select operation. This event is often used to cancel the selecting operation.| - - - -## Examples - The following example demonstrates how to use the property to enable the automatic selection feature of the control. - +> You can programmatically select a row by setting the property. To cancel the selection of a row, set the property to -1. + + You can control the appearance of the selected row by using the property. Common settings usually include a custom background color, foreground color, and font properties. + + The control provides several events that you can use to perform a custom action when a row is selected. The following table lists the available events. + +|Event|Description| +|-----------|-----------------| +||Occurs when a row's Select button is clicked, but after the control handles the select operation. This event is often used to perform a task after a row is selected in the control.| +||Occurs when a row's Select button is clicked, but before the control handles the select operation. This event is often used to cancel the selecting operation.| + + + +## Examples + The following example demonstrates how to use the property to enable the automatic selection feature of the control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSelect/CS/gridviewselectcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: + ]]> @@ -1204,22 +1204,22 @@ Gets or sets the URL to an image to display in the background of a control. The URL of an image to display in the background of the control. The default is an empty string (""), which indicates that this property is not set. - property to specify the URL to an image to display in the background of a control. - + property to specify the URL to an image to display in the background of a control. + > [!NOTE] -> If the specified image is smaller than the control, the image is tiled to fill in the background. If the image is larger than the control, the image is cropped. - - - -## Examples - The following example demonstrates how to use the property to display a custom image in the background of a control. - +> If the specified image is smaller than the control, the image is tiled to fill in the background. If the image is larger than the control, the image is cropped. + + + +## Examples + The following example demonstrates how to use the property to display a custom image in the background of a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewBackImageUrl/CS/gridviewbackimageurlcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewBackImageUrl/VB/gridviewbackimageurlvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewBackImageUrl/VB/gridviewbackimageurlvb.aspx" id="Snippet1"::: + ]]> @@ -1256,24 +1256,24 @@ Gets a object that represents the bottom pager row in a control. A that represents the bottom pager row in the control. - property to `true`), an additional row called the pager row is automatically displayed in the control. The pager row contains controls that allow the user to navigate to the other pages, and can be displayed at the top, the bottom, or both the top and bottom of the control. Use the property to programmatically access the object that represents the bottom pager row in the control. - + property to `true`), an additional row called the pager row is automatically displayed in the control. The pager row contains controls that allow the user to navigate to the other pages, and can be displayed at the top, the bottom, or both the top and bottom of the control. Use the property to programmatically access the object that represents the bottom pager row in the control. + > [!NOTE] -> The property is available only after the control creates the bottom pager row in the event. - - This property is commonly used when you need to programmatically manipulate the bottom pager row, for example when adding custom content. Any modification to the property must be performed after the control has been rendered; otherwise, the control will overwrite any changes. - - - -## Examples - The following example demonstrates how to use the property to access the bottom pager row in a control. The property is used to retrieve a control from the pager row. - +> The property is available only after the control creates the bottom pager row in the event. + + This property is commonly used when you need to programmatically manipulate the bottom pager row, for example when adding custom content. Any modification to the property must be performed after the control has been rendered; otherwise, the control will overwrite any changes. + + + +## Examples + The following example demonstrates how to use the property to access the bottom pager row in a control. The property is used to retrieve a control from the pager row. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewPagerTemplate/CS/gridviewpagertemplatecs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPagerTemplate/VB/gridviewpagertemplatevb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPagerTemplate/VB/gridviewpagertemplatevb.aspx" id="Snippet1"::: + ]]> @@ -1313,21 +1313,21 @@ Gets or sets the text to render in an HTML caption element in a control. This property is provided to make the control more accessible to users of assistive technology devices. A string that represents the text to render in an HTML caption element in a control. The default value is an empty string (""). - property to specify the text to render in an HTML caption element in a control. The text that you specify provides assistive technology devices with a description of the table that can be used to make the control more accessible. You can also specify the position at which to render the HTML caption element by using the property. - - The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and [Globalization and Localization](https://learn.microsoft.com/previous-versions/aspnet/c6zyy3s9(v=vs.100)). - - - -## Examples - The following example demonstrates how to use the property to specify the caption for a control. - + property to specify the text to render in an HTML caption element in a control. The text that you specify provides assistive technology devices with a description of the table that can be used to make the control more accessible. You can also specify the position at which to render the HTML caption element by using the property. + + The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and [Globalization and Localization](https://learn.microsoft.com/previous-versions/aspnet/c6zyy3s9(v=vs.100)). + + + +## Examples + The following example demonstrates how to use the property to specify the caption for a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewCaption/CS/gridviewcaptioncs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewCaption/VB/gridviewcaptionvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewCaption/VB/gridviewcaptionvb.aspx" id="Snippet1"::: + ]]> @@ -1361,34 +1361,34 @@ Gets or sets the horizontal or vertical position of the HTML caption element in a control. This property is provided to make the control more accessible to users of assistive technology devices. One of the values. The default is , which uses the browser's default setting. - property to specify the horizontal or vertical position of the HTML caption element in a control. This property is provided to make the control more accessible to users of assistive technology devices. - - This property is set using one of the enumeration values. The following table lists the possible values. - -|Value|Description| -|-----------|-----------------| -|`TableCaptionAlign.Bottom`|The caption element is aligned with the bottom of the table.| -|`TableCaptionAlign.Left`|The caption element is aligned with the left side of the table.| -|`TableCaptionAlign.NotSet`|The caption element's alignment is not set.| -|`TableCaptionAlign.Right`|The caption element is aligned with the right side of the table.| -|`TableCaptionAlign.Top`|The caption element is aligned with the top of the table.| - + property to specify the horizontal or vertical position of the HTML caption element in a control. This property is provided to make the control more accessible to users of assistive technology devices. + + This property is set using one of the enumeration values. The following table lists the possible values. + +|Value|Description| +|-----------|-----------------| +|`TableCaptionAlign.Bottom`|The caption element is aligned with the bottom of the table.| +|`TableCaptionAlign.Left`|The caption element is aligned with the left side of the table.| +|`TableCaptionAlign.NotSet`|The caption element's alignment is not set.| +|`TableCaptionAlign.Right`|The caption element is aligned with the right side of the table.| +|`TableCaptionAlign.Top`|The caption element is aligned with the top of the table.| + > [!NOTE] -> When this property is set to `TableCaptionAlign.NotSet`, the default value of the browser is used. - - To specify the text for the HTML caption element, use the property. - - - -## Examples - The following example demonstrates how to use the property to specify that the caption element for a control is aligned with the top of the control. - +> When this property is set to `TableCaptionAlign.NotSet`, the default value of the browser is used. + + To specify the text for the HTML caption element, use the property. + + + +## Examples + The following example demonstrates how to use the property to specify that the caption element for a control is aligned with the top of the control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewCaption/CS/gridviewcaptioncs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewCaption/VB/gridviewcaptionvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewCaption/VB/gridviewcaptionvb.aspx" id="Snippet1"::: + ]]> The specified value is not one of the enumeration values. @@ -1424,21 +1424,21 @@ Gets or sets the amount of space between the contents of a cell and the cell's border. The amount of space, in pixels, between the contents of a cell and the cell's border. The default value is -1, which indicates that this property is not set. - property to control the spacing between the contents of a cell and the cell's border. The padding amount specified is added to all four sides of the cell. - - All cells in the same column of a control have the same width. The padding amount is applied to the widest cell and all other cells in the column have this cell width. Similarly, all cells in the same row have the same height. The padding amount is applied to the tallest cell in the row and all other cells in the row have this cell height. Individual cell sizes cannot be specified. - - - -## Examples - The following example demonstrates how to use the property to declaratively set the amount of space between the contents of a cell and the cell's border. - + property to control the spacing between the contents of a cell and the cell's border. The padding amount specified is added to all four sides of the cell. + + All cells in the same column of a control have the same width. The padding amount is applied to the widest cell and all other cells in the column have this cell width. Similarly, all cells in the same row have the same height. The padding amount is applied to the tallest cell in the row and all other cells in the row have this cell height. Individual cell sizes cannot be specified. + + + +## Examples + The following example demonstrates how to use the property to declaratively set the amount of space between the contents of a cell and the cell's border. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewCellPadding/CS/gridviewcellpaddingcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewCellPadding/VB/gridviewcellpaddingvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewCellPadding/VB/gridviewcellpaddingvb.aspx" id="Snippet1"::: + ]]> @@ -1471,22 +1471,22 @@ Gets or sets the amount of space between cells. The amount of space, in pixels, between cells. The default value is 0. - property to control the spacing between adjacent cells in the control. This spacing is applied both vertically and horizontally. The cell spacing is uniform for the entire control. Individual cell spacing between rows or columns cannot be specified. - + property to control the spacing between adjacent cells in the control. This spacing is applied both vertically and horizontally. The cell spacing is uniform for the entire control. Individual cell spacing between rows or columns cannot be specified. + > [!NOTE] -> If you set this property to a value greater than 0 and then set the property to a value that displays the cell borders, a gap is displayed between the borders of adjacent cells. In this situation, the property controls the size of the gap. - - - -## Examples - The following example demonstrates how to use the property to declaratively set the amount of space between the cells of a control. - +> If you set this property to a value greater than 0 and then set the property to a value that displays the cell borders, a gap is displayed between the borders of adjacent cells. In this situation, the property controls the size of the gap. + + + +## Examples + The following example demonstrates how to use the property to declaratively set the amount of space between the cells of a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewCellPadding/CS/gridviewcellpaddingcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewCellPadding/VB/gridviewcellpaddingvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewCellPadding/VB/gridviewcellpaddingvb.aspx" id="Snippet1"::: + ]]> @@ -1522,11 +1522,11 @@ Gets or sets the names of the data fields whose values are appended to the property value to uniquely identify each instance of a data-bound control. The names of the data fields whose values are used to uniquely identify each instance of a data-bound control when ASP.NET generates the value. - control, ASP.NET generates a unique value for each instance. You specify how the value is generated by setting the property. If you set the property to , ASP.NET will generate the by appending a suffix that is derived from the data field or fields that are specified in . If is not set, the suffix is a sequential number. - + control, ASP.NET generates a unique value for each instance. You specify how the value is generated by setting the property. If you set the property to , ASP.NET will generate the by appending a suffix that is derived from the data field or fields that are specified in . If is not set, the suffix is a sequential number. + ]]> @@ -1609,38 +1609,38 @@ Gets a collection of objects that represent the column fields in a control. A that contains all the column fields in the control. - control. The property (collection) is used to store all the explicitly declared column fields that get rendered in the control. You can also use the collection to programmatically manage the collection of column fields. - + control. The property (collection) is used to store all the explicitly declared column fields that get rendered in the control. You can also use the collection to programmatically manage the collection of column fields. + > [!NOTE] -> Explicitly declared column fields can be used 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. Automatically generated column fields are not added to the collection. - - The column fields are displayed in the control in the order that the column fields appear in the collection. The following table shows the different column field classes that derive from the class and can be used in the collection. - -|Column field type|Description| -|-----------------------|-----------------| -||Displays the value of a field in a data source. This is the default column type of the control.| -||Displays a command button for each item in the control. This enables you to create a column of custom button controls, such as the Add or the Remove button.| -||Displays a check box for each item in the control. This column field type is commonly used to display fields with a Boolean value.| -||Displays predefined command buttons to perform select, edit, or delete operations.| -||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.| -||Displays an image for each item in the control.| -||Displays user-defined content for each item in the control, according to a specified template. This column field type enables you to create a custom column field.| - - Although you can programmatically add column fields to the collection, it is easier to list the column fields declaratively in the control and then use the property of each column field to show or hide each column field. - - If the property of a column field is set to `false`, the column is not displayed in the control and the data for the column does not make a round trip to the client. If you want the data for a column that is not visible to make a round trip, add the field name to the property. - - - -## Examples - The following example demonstrates how to populate the collection declaratively. - +> Explicitly declared column fields can be used 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. Automatically generated column fields are not added to the collection. + + The column fields are displayed in the control in the order that the column fields appear in the collection. The following table shows the different column field classes that derive from the class and can be used in the collection. + +|Column field type|Description| +|-----------------------|-----------------| +||Displays the value of a field in a data source. This is the default column type of the control.| +||Displays a command button for each item in the control. This enables you to create a column of custom button controls, such as the Add or the Remove button.| +||Displays a check box for each item in the control. This column field type is commonly used to display fields with a Boolean value.| +||Displays predefined command buttons to perform select, edit, or delete operations.| +||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.| +||Displays an image for each item in the control.| +||Displays user-defined content for each item in the control, according to a specified template. This column field type enables you to create a custom column field.| + + Although you can programmatically add column fields to the collection, it is easier to list the column fields declaratively in the control and then use the property of each column field to show or hide each column field. + + If the property of a column field is set to `false`, the column is not displayed in the control and the data for the column does not make a round trip to the client. If you want the data for a column that is not visible to make a round trip, add the field name to the property. + + + +## Examples + The following example demonstrates how to populate the collection declaratively. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewColumnFields/CS/gridviewcolumnfieldscs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewColumnFields/VB/gridviewcolumnfieldsvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewColumnFields/VB/gridviewcolumnfieldsvb.aspx" id="Snippet1"::: + ]]> @@ -1693,11 +1693,11 @@ Gets or sets the control that will automatically generate the columns for a control that uses ASP.NET Dynamic Data features. The control that will automatically generate the columns for a control that uses ASP.NET Dynamic Data features. - control to the page. This enables ASP.NET Dynamic Data features for data-bound controls in a page, such as control. To enable an individual control to use Dynamic Data features, you must associate it with the control by calling the method during the `Page_Init` event. This method automatically sets the property to the object. - + control to the page. This enables ASP.NET Dynamic Data features for data-bound controls in a page, such as control. To enable an individual control to use Dynamic Data features, you must associate it with the control by calling the method during the `Page_Init` event. This method automatically sets the property to the object. + ]]> @@ -1732,14 +1732,14 @@ Creates an automatically generated column field. An that represents the automatically generated column field specified by the parameter. - method is used to create an automatically generated column field when the property is set to `true`. The properties of the automatically generated column field are specified through the object contained in the `fieldProperties` parameter. - + method is used to create an automatically generated column field when the property is set to `true`. The properties of the automatically generated column field are specified through the object contained in the `fieldProperties` parameter. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> @@ -1773,29 +1773,29 @@ Creates the control hierarchy used to render the control using the specified data source. The number of rows created. - method is used to create the control hierarchy of the control. - + method is used to create the control hierarchy of the control. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> - returns a null . - - -or- - - does not implement the interface and cannot return a . - - -or- - - is and does not implement the interface and cannot perform data source paging. - - -or- - + returns a null . + + -or- + + does not implement the interface and cannot return a . + + -or- + + is and does not implement the interface and cannot perform data source paging. + + -or- + does not implement the interface and is set to . @@ -1821,11 +1821,11 @@ Creates a new child table. Always returns a new that represents the child table. - method is a helper method used by the control to create a child table. - + method is a helper method used by the control to create a child table. + ]]> @@ -1858,14 +1858,14 @@ Creates the set of column fields used to build the control hierarchy. A that contains the fields used to build the control hierarchy. - property is set to `true`, a bound column field is automatically created for each field in the data source. Each bound column field is then displayed as a row in the control in the order that the fields appear in the data source. The method is used to create the automatically generated column fields. - + property is set to `true`, a bound column field is automatically created for each field in the data source. Each bound column field is then displayed as a row in the control in the order that the fields appear in the data source. The method is used to create the automatically generated column fields. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> @@ -1893,14 +1893,14 @@ Creates the default style for the control. A that represents the style for the control. - method is used to create the default style for the control. - + method is used to create the default style for the control. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> @@ -1927,11 +1927,11 @@ Creates the object that contains the arguments that get passed to the data source for processing. A that contains the arguments that get passed to the data source. - method is a helper method called by the control to create the object that contains the arguments passed to the data source. In this implementation, the object contains the arguments for paging operations. - + method is a helper method called by the control to create the object that contains the arguments passed to the data source. In this implementation, the object contains the arguments for paging operations. + ]]> @@ -1971,14 +1971,14 @@ Creates a row in the control. A created using the specified parameters. - method is used to create a row in the control. - + method is used to create a row in the control. + > [!NOTE] -> This method is used primarily by control developers to extend the control. A data-bound control automatically generates the rows needed to display the target data. - +> This method is used primarily by control developers to extend the control. A data-bound control automatically generates the rows needed to display the target data. + ]]> @@ -2006,23 +2006,23 @@ Binds the data source to the control. This method cannot be inherited. - method to bind data from a data source to the control. This method resolves all data-binding expressions in the active template of the control. - - The method is called automatically if the property of the control refers to a valid data source control. - - Instead of manually calling the method, you can use model binding with your control by setting the property to the name of a method that returns data for the . The is then automatically populated with the data that is returned from the select method. Model binding can simplify your code for working with data. For more information, see [Model Binding and Web Forms](/aspnet/web-forms/overview/presenting-and-managing-data/model-binding/retrieving-data). - - - -## Examples - The following example demonstrates how to use the method to bind a data source to a control. - + method to bind data from a data source to the control. This method resolves all data-binding expressions in the active template of the control. + + The method is called automatically if the property of the control refers to a valid data source control. + + Instead of manually calling the method, you can use model binding with your control by setting the property to the name of a method that returns data for the . The is then automatically populated with the data that is returned from the select method. Model binding can simplify your code for working with data. For more information, see [Model Binding and Web Forms](/aspnet/web-forms/overview/presenting-and-managing-data/model-binding/retrieving-data). + + + +## Examples + The following example demonstrates how to use the method to bind a data source to a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewDataBind/CS/gridviewdatabindcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewDataBind/VB/gridviewdatabindvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewDataBind/VB/gridviewdatabindvb.aspx" id="Snippet1"::: + ]]> @@ -2066,36 +2066,36 @@ Gets or sets an array that contains the names of the primary key fields for the items displayed in a control. An array that contains the names of the primary key fields for the items displayed in a control. - property to specify the field or fields that represent the primary key of the data source. You should only set this property to the field or fields that are required to uniquely identify each row; for example, the ID column if an integer value uniquely identifies each row. You must set the property in order for the automatic update and delete features of the control to work. The values of these key fields are passed to the data source control in order to specify the row to update or delete. - - If you need to retrieve the data key value when updating or deleting a row, use the `Keys` property of either the or class. For example, `e.Keys[0]` holds the value of the first data key in a or event handler. - - If you need to retrieve the data key value when a row is selected, use the property. - - When the property is set, the control automatically populates its collection with the values from the specified field or fields, which provides a convenient way to access the primary keys of each row. - + property to specify the field or fields that represent the primary key of the data source. You should only set this property to the field or fields that are required to uniquely identify each row; for example, the ID column if an integer value uniquely identifies each row. You must set the property in order for the automatic update and delete features of the control to work. The values of these key fields are passed to the data source control in order to specify the row to update or delete. + + If you need to retrieve the data key value when updating or deleting a row, use the `Keys` property of either the or class. For example, `e.Keys[0]` holds the value of the first data key in a or event handler. + + If you need to retrieve the data key value when a row is selected, use the property. + + When the property is set, the control automatically populates its collection with the values from the specified field or fields, which provides a convenient way to access the primary keys of each row. + > [!NOTE] -> The control stores these key field values in the control state. If these values contain sensitive information, it is strongly recommended that you enable view-state encryption by setting the property to `ViewStateEncryptionMode.Always`. - - When you use automatically generated field columns (by setting the property to `true`), the control makes sure that the columns that correspond to the field or fields specified in the property are read-only. - - If the property of a column field is set to `false`, the column is not displayed in the control and the data for the column does not make a round trip to the client. If you want the data for a column that is not visible to be available to the client, add the field name to the property. - - - -## Examples - The following example demonstrates how to use the property to specify the key field of the data source. In the example, the `DataKeyNames` attribute of the `GridView` element in markup specifies two key fields by using a comma to separate the names. To run this example, create a Web site that has the following: - -- A connection to the AdventureWorksLT sample database and a connection string that is named `AdventureWorksLTConnectionString`. For information about how to set up the AdventureWorksLT sample database, see [How to: Set Up an AdventureWorksLT Sample Database for ASP.NET Development](https://learn.microsoft.com/previous-versions/dd410121(v=vs.140)). - -- A LINQ-to-SQL data context class that is named `AdventureWorksLTDataClassesDataContext`. The data context must have a class for the SalesOrderDetails table. For information about how to create LINQ-to-SQL classes, see [LINQ to SQL](/dotnet/framework/data/adonet/sql/linq/). - +> The control stores these key field values in the control state. If these values contain sensitive information, it is strongly recommended that you enable view-state encryption by setting the property to `ViewStateEncryptionMode.Always`. + + When you use automatically generated field columns (by setting the property to `true`), the control makes sure that the columns that correspond to the field or fields specified in the property are read-only. + + If the property of a column field is set to `false`, the column is not displayed in the control and the data for the column does not make a round trip to the client. If you want the data for a column that is not visible to be available to the client, add the field name to the property. + + + +## Examples + The following example demonstrates how to use the property to specify the key field of the data source. In the example, the `DataKeyNames` attribute of the `GridView` element in markup specifies two key fields by using a comma to separate the names. To run this example, create a Web site that has the following: + +- A connection to the AdventureWorksLT sample database and a connection string that is named `AdventureWorksLTConnectionString`. For information about how to set up the AdventureWorksLT sample database, see [How to: Set Up an AdventureWorksLT Sample Database for ASP.NET Development](https://learn.microsoft.com/previous-versions/dd410121(v=vs.140)). + +- A LINQ-to-SQL data context class that is named `AdventureWorksLTDataClassesDataContext`. The data context must have a class for the SalesOrderDetails table. For information about how to create LINQ-to-SQL classes, see [LINQ to SQL](/dotnet/framework/data/adonet/sql/linq/). + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewEdit/CS/editorders.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewEdit/VB/editorders.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewEdit/VB/editorders.aspx" id="Snippet1"::: + ]]> @@ -2135,22 +2135,22 @@ Gets a collection of objects that represent the data key value of each row in a control. A that contains the data key of each row in a control. - property is set, the control automatically creates a object for each row in the control. The object contains the values of the field or fields specified in the property. The objects are then added to the control's collection. Use the property to retrieve the object for a specific data row in the control. - + property is set, the control automatically creates a object for each row in the control. The object contains the values of the field or fields specified in the property. The objects are then added to the control's collection. Use the property to retrieve the object for a specific data row in the control. + > [!NOTE] -> You can use the property to retrieve the object for the currently selected row. You can also use the property to retrieve the data key value for the currently selected row directly. - - - -## Examples - The following example demonstrates how to use the property to determine the data key value of the selected row in a control. - +> You can use the property to retrieve the object for the currently selected row. You can also use the property to retrieve the data key value for the currently selected row directly. + + + +## Examples + The following example demonstrates how to use the property to determine the data key value of the selected row in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewDataKeys/CS/gridviewdatakeyscs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewDataKeys/VB/gridviewdatakeysvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewDataKeys/VB/gridviewdatakeysvb.aspx" id="Snippet1"::: + ]]> @@ -2190,13 +2190,13 @@ Gets or sets the name of the method to call in order to delete data. The name of the method. - @@ -2224,19 +2224,19 @@ The index of the row to delete. Deletes the record at the specified index from the data source. - method to programmatically delete the record at the specified index from the data source. This method is commonly used when you need to delete a record from outside of the control, such as from a different control on the page. Calling this method also raises the and events. - - - -## Examples - The following example demonstrates how to use the method to programmatically delete a record in a control. - + method to programmatically delete the record at the specified index from the data source. This method is commonly used when you need to delete a record from outside of the control, such as from a different control on the page. Calling this method also raises the and events. + + + +## Examples + The following example demonstrates how to use the method to programmatically delete a record in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewDeleteRow/CS/GridViewDeleteRowcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewDeleteRow/VB/GridViewDeleteRowvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewDeleteRow/VB/GridViewDeleteRowvb.aspx" id="Snippet1"::: + ]]> The control is not bound to a data source control. @@ -2277,33 +2277,33 @@ Gets or sets the index of the row to edit. The zero-based index of the row to edit. The default is -1, which indicates that no row is being edited. - control to open in edit mode for a specific row the first time that the page is displayed. To do this, you can set the property in the handler for the event of the class or of the control. - -- You want to know which row was edited after the row was updated. To do this, you can retrieve the row index from the property in the event handler. - -- You are binding the control to a data source by setting the property programmatically. In this case you must set the property in the and event handlers. - - If you set the property after a postback or in handlers for events that are raised later than the event, the control might not enter edit mode for the specified row. If you read the value of this property in other event handlers, the index is not guaranteed to reflect the row that is being edited. - - To determine which row the user has clicked an **Edit** button or hyperlink in before the control enters edit mode, you can retrieve the row index from the property of the object in the event handler. - - To prevent the control from entering edit mode after a user has clicked an **Edit** button or hyperlink, set the property of the object to `true` in the event handler. - - - -## Examples - The following example demonstrates how to use the property to determine which row was updated after it was edited in a control. A message is displayed to indicate that the update was successful. - + control to open in edit mode for a specific row the first time that the page is displayed. To do this, you can set the property in the handler for the event of the class or of the control. + +- You want to know which row was edited after the row was updated. To do this, you can retrieve the row index from the property in the event handler. + +- You are binding the control to a data source by setting the property programmatically. In this case you must set the property in the and event handlers. + + If you set the property after a postback or in handlers for events that are raised later than the event, the control might not enter edit mode for the specified row. If you read the value of this property in other event handlers, the index is not guaranteed to reflect the row that is being edited. + + To determine which row the user has clicked an **Edit** button or hyperlink in before the control enters edit mode, you can retrieve the row index from the property of the object in the event handler. + + To prevent the control from entering edit mode after a user has clicked an **Edit** button or hyperlink, set the property of the object to `true` in the event handler. + + + +## Examples + The following example demonstrates how to use the property to determine which row was updated after it was edited in a control. A message is displayed to indicate that the update was successful. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRows/CS/gridviewrowscs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRows/VB/gridviewrowsvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRows/VB/gridviewrowsvb.aspx" id="Snippet1"::: + ]]> The specified index is less than -1. @@ -2349,25 +2349,25 @@ Gets a reference to the object that enables you to set the appearance of the row selected for editing in a control. A reference to the that represents the style of the row being edited in a control. - property to control the appearance of the row being edited in a control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: - -- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `EditRowStyle-ForeColor`). - -- Nest an `` element between the opening and closing tags of the control. - - The properties can also be set programmatically in the form `Property.Subproperty` (for example, `EditRowStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. - - - -## Examples - The following example demonstrates how to use the property to define a custom style for the row being edited in a control. - + property to control the appearance of the row being edited in a control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: + +- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `EditRowStyle-ForeColor`). + +- Nest an `` element between the opening and closing tags of the control. + + The properties can also be set programmatically in the form `Property.Subproperty` (for example, `EditRowStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. + + + +## Examples + The following example demonstrates how to use the property to define a custom style for the row being edited in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewEditRowStyle/CS/gridvieweditrowstylecs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewEditRowStyle/VB/gridvieweditrowstylevb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewEditRowStyle/VB/gridvieweditrowstylevb.aspx" id="Snippet1"::: + ]]> @@ -2414,25 +2414,25 @@ Gets a reference to the object that enables you to set the appearance of the empty data row rendered when a control is bound to a data source that does not contain any records. A reference to the that enables you to set the appearance of the null row. - property to control the appearance of the null row in a control. The null row is displayed when the data source that is bound to the control does not contain any records. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: - -- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `EmptyDataRowStyle-ForeColor`). - -- Nest an `` element between the opening and closing tags of the control. - - The properties can also be set programmatically in the form `Property.Subproperty` (for example, `EmptyDataRowStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. - - - -## Examples - The following example demonstrates how to set the property declaratively to specify a light blue background and a red font for the null row. - + property to control the appearance of the null row in a control. The null row is displayed when the data source that is bound to the control does not contain any records. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: + +- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `EmptyDataRowStyle-ForeColor`). + +- Nest an `` element between the opening and closing tags of the control. + + The properties can also be set programmatically in the form `Property.Subproperty` (for example, `EmptyDataRowStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. + + + +## Examples + The following example demonstrates how to set the property declaratively to specify a light blue background and a red font for the null row. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewNullRowTemplate/CS/gridviewnullrowtemplatecs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewNullRowTemplate/VB/gridviewnullrowtemplatevb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewNullRowTemplate/VB/gridviewnullrowtemplatevb.aspx" id="Snippet1"::: + ]]> @@ -2493,26 +2493,26 @@ Gets or sets the user-defined content for the empty data row rendered when a control is bound to a data source that does not contain any records. A that contains the custom content for the empty data row. The default value is , which indicates that this property is not set. - control when the data source that is bound to the control does not contain any records. You can define your own custom user interface (UI) for the empty data row by using the property. - - To specify a custom template for the empty data row, first place `` tags between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing `` tags. To control the style of the empty data row, use the property. Alternatively, you can use the built-in UI for the empty data row by setting the property instead of this property. - - For information about how to programmatically access controls that you declare in an empty data template, see [How to: Access Server Controls by ID](https://learn.microsoft.com/previous-versions/aspnet/y81z8326(v=vs.100)). - + control when the data source that is bound to the control does not contain any records. You can define your own custom user interface (UI) for the empty data row by using the property. + + To specify a custom template for the empty data row, first place `` tags between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing `` tags. To control the style of the empty data row, use the property. Alternatively, you can use the built-in UI for the empty data row by setting the property instead of this property. + + For information about how to programmatically access controls that you declare in an empty data template, see [How to: Access Server Controls by ID](https://learn.microsoft.com/previous-versions/aspnet/y81z8326(v=vs.100)). + > [!NOTE] -> If both the and properties are set, the property takes precedence. - - - -## Examples - The following example demonstrates how to define a custom template for the empty data row displayed when a control is bound to a data source that does not contain any records. - +> If both the and properties are set, the property takes precedence. + + + +## Examples + The following example demonstrates how to define a custom template for the empty data row displayed when a control is bound to a data source that does not contain any records. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewNullRowTemplate/CS/gridviewnullrowtemplatecs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewNullRowTemplate/VB/gridviewnullrowtemplatevb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewNullRowTemplate/VB/gridviewnullrowtemplatevb.aspx" id="Snippet1"::: + ]]> @@ -2551,24 +2551,24 @@ Gets or sets the text to display in the empty data row rendered when a control is bound to a data source that does not contain any records. The text to display in the empty data row. The default is an empty string (""), which indicates that this property is not set. - control when the data source that is bound to the control does not contain any records. Use the property to specify the text to display in the empty data row. To control the style of the empty data row, use the property. Alternatively, you can define your own custom user interface (UI) for the empty data row by setting the property instead of this property. - + control when the data source that is bound to the control does not contain any records. Use the property to specify the text to display in the empty data row. To control the style of the empty data row, use the property. Alternatively, you can define your own custom user interface (UI) for the empty data row by setting the property instead of this property. + > [!NOTE] -> If both the and properties are set, the property takes precedence. - - The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and [Globalization and Localization](https://learn.microsoft.com/previous-versions/aspnet/c6zyy3s9(v=vs.100)). - - - -## Examples - The following example demonstrates how to use the property to specify the text to display in the empty data row. - +> If both the and properties are set, the property takes precedence. + + The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and [Globalization and Localization](https://learn.microsoft.com/previous-versions/aspnet/c6zyy3s9(v=vs.100)). + + + +## Examples + The following example demonstrates how to use the property to specify the text to display in the empty data row. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/gridviewemptydatatext/CS/gridviewemptydatatextcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewemptydatatext/VB/gridviewemptydatatextvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewemptydatatext/VB/gridviewemptydatatextvb.aspx" id="Snippet1"::: + ]]> @@ -2634,11 +2634,11 @@ if the row selection is based on data-key values; otherwise, . The default value is . - @@ -2670,24 +2670,24 @@ to use client-side callbacks for sorting and paging operations; otherwise, . The default is . - control posts back to the server to perform the operation. When the property is set to `true`, a service is called on the client to perform sorting and paging operations, which eliminates the need to post back to the server. - + control posts back to the server to perform the operation. When the property is set to `true`, a service is called on the client to perform sorting and paging operations, which eliminates the need to post back to the server. + > [!NOTE] -> Not all browsers support this feature. To determine whether a browser supports this feature, use the property. - - All columns in the collection must support callbacks for this feature to work. If the collection contains a column that does not support callbacks, such as , a exception is raised. - - - -## Examples - The following example demonstrates how to use the property to enable client-side callbacks for sorting and paging operations. - +> Not all browsers support this feature. To determine whether a browser supports this feature, use the property. + + All columns in the collection must support callbacks for this feature to work. If the collection contains a column that does not support callbacks, such as , a exception is raised. + + + +## Examples + The following example demonstrates how to use the property to enable client-side callbacks for sorting and paging operations. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/gridviewenablesortingandpagingcallbacks/CS/gridviewenablesortingandpagingcallbackscs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewenablesortingandpagingcallbacks/VB/gridviewenablesortingandpagingcallbacksvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewenablesortingandpagingcallbacks/VB/gridviewenablesortingandpagingcallbacksvb.aspx" id="Snippet1"::: + ]]> The collection contains a column that does not support callbacks, such as . @@ -2727,11 +2727,11 @@ to include the primary key field or fields; otherwise, . Retrieves the values of each field declared within the specified row and stores them in the specified object. - method is a helper method called by the control to retrieve the values of each field declared within the row specified by the `row` parameter. You can specify whether the extracted values include read-only fields and key fields by using the `includeReadOnlyFields` and `includePrimaryKey` parameters, respectively. - + method is a helper method called by the control to retrieve the values of each field declared within the row specified by the `row` parameter. You can specify whether the extracted values include read-only fields and key fields by using the `includeReadOnlyFields` and `includePrimaryKey` parameters, respectively. + ]]> @@ -2771,24 +2771,24 @@ Gets a object that represents the footer row in a control. A that represents the footer row in a control. - property to programmatically access the object that represents the footer row in a control. - + property to programmatically access the object that represents the footer row in a control. + > [!NOTE] -> The property is available only after the control creates the footer row in the event. - - This property is commonly used when you need to programmatically manipulate the footer row, for example when adding custom content. Any modification to the property must be performed after the control has been rendered; otherwise, the control will overwrite any changes. - - - -## Examples - The following example demonstrates how to use the property to display the sort direction in the footer row. - +> The property is available only after the control creates the footer row in the event. + + This property is commonly used when you need to programmatically manipulate the footer row, for example when adding custom content. Any modification to the property must be performed after the control has been rendered; otherwise, the control will overwrite any changes. + + + +## Examples + The following example demonstrates how to use the property to display the sort direction in the footer row. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/gridviewfooterrow/CS/gridviewfooterrowcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewfooterrow/VB/gridviewfooterrowvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewfooterrow/VB/gridviewfooterrowvb.aspx" id="Snippet1"::: + ]]> @@ -2836,25 +2836,25 @@ Gets a reference to the object that enables you to set the appearance of the footer row in a control. A reference to the that represents the style of the footer row in a control. - property to control the appearance of the footer row in a control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: - -- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `FooterStyle-ForeColor`). - -- Nest a `` element between the opening and closing tags of the control. - - The properties can also be set programmatically in the form `Property.Subproperty` (for example, `FooterStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. - - - -## Examples - The following example demonstrates how to use the property to define a custom style for the footer row in a control. - + property to control the appearance of the footer row in a control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: + +- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `FooterStyle-ForeColor`). + +- Nest a `` element between the opening and closing tags of the control. + + The properties can also be set programmatically in the form `Property.Subproperty` (for example, `FooterStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. + + + +## Examples + The following example demonstrates how to use the property to define a custom style for the footer row in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewShowHeader/CS/gridviewshowheadercs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewShowHeader/VB/gridviewshowheadervb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewShowHeader/VB/gridviewshowheadervb.aspx" id="Snippet1"::: + ]]> @@ -2888,11 +2888,11 @@ Returns the result of a callback event that targets a control. The results of the callback. - control implements the interface and uses the to asynchronously retrieve data and the method to return the retrieved data to the control. - + control implements the interface and uses the to asynchronously retrieve data and the method to return the retrieved data to the control. + ]]> @@ -2923,11 +2923,11 @@ Creates the callback script for a button that performs a sorting operation. The callback script for a button that performs a sorting operation. - method is a helper method used by the control to create the callback script for a button that performs a sorting operation. - + method is a helper method used by the control to create the callback script for a button that performs a sorting operation. + ]]> @@ -2959,26 +2959,26 @@ Gets or sets the gridline style for a control. One of the values. The default is . - property to specify the gridline style for a control. The following table lists the available styles. - -|Style|Description| -|-----------|-----------------| -|`GridLines.None`|No gridlines are displayed.| -|`GridLines.Horizontal`|Displays the horizontal gridlines only.| -|`GridLines.Vertical`|Displays the vertical gridlines only.| -|`GridLines.Both`|Displays both the horizontal and vertical gridlines.| - - - -## Examples - The following example demonstrates how to use the property to hide the gridlines in a control. - + property to specify the gridline style for a control. The following table lists the available styles. + +|Style|Description| +|-----------|-----------------| +|`GridLines.None`|No gridlines are displayed.| +|`GridLines.Horizontal`|Displays the horizontal gridlines only.| +|`GridLines.Vertical`|Displays the vertical gridlines only.| +|`GridLines.Both`|Displays both the horizontal and vertical gridlines.| + + + +## Examples + The following example demonstrates how to use the property to hide the gridlines in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewGridLines/CS/gridviewgridlinescs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewGridLines/VB/gridviewgridlinesvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewGridLines/VB/gridviewgridlinesvb.aspx" id="Snippet1"::: + ]]> @@ -3016,24 +3016,24 @@ Gets a object that represents the header row in a control. A that represents the header row in a control. - property to programmatically access the object that represents the header row in a control. - + property to programmatically access the object that represents the header row in a control. + > [!NOTE] -> The property is available only after the control creates the header row in the event. - - This property is commonly used when you need to programmatically manipulate the header row, for example, when adding custom content. Any modification to the property must be performed after the control has been rendered; otherwise, the control will overwrite any changes. - - - -## Examples - The following example demonstrates how to use the property to programmatically change the font color of the header row based on the sort direction. - +> The property is available only after the control creates the header row in the event. + + This property is commonly used when you need to programmatically manipulate the header row, for example, when adding custom content. Any modification to the property must be performed after the control has been rendered; otherwise, the control will overwrite any changes. + + + +## Examples + The following example demonstrates how to use the property to programmatically change the font color of the header row based on the sort direction. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/gridviewfooterrow/CS/gridviewfooterrowcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewfooterrow/VB/gridviewfooterrowvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewfooterrow/VB/gridviewfooterrowvb.aspx" id="Snippet1"::: + ]]> @@ -3081,25 +3081,25 @@ Gets a reference to the object that enables you to set the appearance of the header row in a control. A reference to the that represents the style of the header row in a control. - property to control the appearance of the header row in a control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: - -- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `HeaderStyle-ForeColor`). - -- Nest a `` element between the opening and closing tags of the control. - - The properties can also be set programmatically in the form `Property.Subproperty` (for example, `HeaderStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. - - - -## Examples - The following example demonstrates how to use the property to define a custom style for the header row in a control. - + property to control the appearance of the header row in a control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: + +- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `HeaderStyle-ForeColor`). + +- Nest a `` element between the opening and closing tags of the control. + + The properties can also be set programmatically in the form `Property.Subproperty` (for example, `HeaderStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. + + + +## Examples + The following example demonstrates how to use the property to define a custom style for the header row in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewShowHeader/CS/gridviewshowheadercs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewShowHeader/VB/gridviewshowheadervb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewShowHeader/VB/gridviewshowheadervb.aspx" id="Snippet1"::: + ]]> @@ -3142,27 +3142,27 @@ Gets or sets the horizontal alignment of a control on the page. One of the values. The default is . - property to specify the horizontal alignment of a control within the page. The following table lists the different horizontal alignment styles. - -|Alignment value|Description| -|---------------------|-----------------| -|`HorizontalAlign.NotSet`|The horizontal alignment of the control has not been set.| -|`HorizontalAlign.Left`|The control is left-aligned on the page.| -|`HorizontalAlign.Center`|The control is centered on the page.| -|`HorizontalAlign.Right`|The control is right-aligned on the page.| -|`HorizontalAlign.Justify`|The control is aligned with both the left and right margins of the page.| - - - -## Examples - The following example demonstrates how to use the property to align a control on the right side of a page. - + property to specify the horizontal alignment of a control within the page. The following table lists the different horizontal alignment styles. + +|Alignment value|Description| +|---------------------|-----------------| +|`HorizontalAlign.NotSet`|The horizontal alignment of the control has not been set.| +|`HorizontalAlign.Left`|The control is left-aligned on the page.| +|`HorizontalAlign.Center`|The control is centered on the page.| +|`HorizontalAlign.Right`|The control is right-aligned on the page.| +|`HorizontalAlign.Justify`|The control is aligned with both the left and right margins of the page.| + + + +## Examples + The following example demonstrates how to use the property to align a control on the right side of a page. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewHorizontalAlign/CS/gridviewhorizontalaligncs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewHorizontalAlign/VB/gridviewhorizontalalignvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewHorizontalAlign/VB/gridviewhorizontalalignvb.aspx" id="Snippet1"::: + ]]> @@ -3195,14 +3195,14 @@ A that represents the data source. Initializes the pager row displayed when the paging feature is enabled. - method is used to initialize the pager row displayed when the paging feature is enabled. - + method is used to initialize the pager row displayed when the paging feature is enabled. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> @@ -3234,14 +3234,14 @@ An array of objects that represent the column fields in the control. Initializes a row in the control. - method is used to initialize a row in the control. - + method is used to initialize a row in the control. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> @@ -3273,43 +3273,43 @@ if the specified data type can be bound to a column in a control; otherwise, . - method is a helper method that is commonly used by control developers to programmatically determine whether the specified data type can be bound to a column in a control. The following data types can be bound to a column in a control: - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - + method is a helper method that is commonly used by control developers to programmatically determine whether the specified data type can be bound to a column in a control. The following data types can be bound to a column in a control: + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + ]]> @@ -3338,14 +3338,14 @@ An that contains the saved control state values for the control. Loads the state of the properties in the control that need to be persisted, even when the property is set to . - control that need to be persisted, even when the property is set to `false`. - + control that need to be persisted, even when the property is set to `false`. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> @@ -3374,11 +3374,11 @@ An that contains the saved view state values for the control. Loads the previously saved view state of the control. - @@ -3411,11 +3411,11 @@ if the event has been canceled; otherwise, . - method implements the method to pass events from child controls to the page hierarchy. - + method implements the method to pass events from child controls to the page hierarchy. + ]]> @@ -3444,11 +3444,11 @@ Rebinds the control to its data after the , , or property is changed. - method is a helper method used by the control to rebind the control to its data after the , , or property is changed. - + method is a helper method used by the control to rebind the control to its data after the , , or property is changed. + ]]> @@ -3485,15 +3485,15 @@ An that contains the event data. Raises the event. - method notifies a control that the underlying data source has changed and that the control should rebind. Typically, the method is called when a property of the data source view has changed. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + method notifies a control that the underlying data source has changed and that the control should rebind. Typically, the method is called when a property of the data source view has changed. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> @@ -3526,15 +3526,15 @@ An that contains event data. Raises the event. - 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. - + 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. + ]]> @@ -3565,15 +3565,15 @@ An that contains event data. Raises the event. - event is raised when one of the pager buttons is clicked, but after the control handles the paging operation. This enables you to provide an event-handling method that performs a custom routine, such as a custom paging operation, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + event is raised when one of the pager buttons is clicked, but after the control handles the paging operation. This enables you to provide an event-handling method that performs a custom routine, such as a custom paging operation, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> @@ -3608,15 +3608,15 @@ A that contains event data. Raises the event. - event is raised when one of the pager buttons is clicked, but before the control handles the paging operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the paging operation, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + event is raised when one of the pager buttons is clicked, but before the control handles the paging operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the paging operation, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> There is no handler for the event. @@ -3682,15 +3682,15 @@ An that contains the event data. Raises the event. - 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. - + 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. + ]]> @@ -3722,15 +3722,15 @@ A that contains event data. Raises the event. - event is raised when the Cancel button of a row in edit mode is clicked, but before the row exits edit mode. This enables you to provide an event-handling method that performs a custom routine, such as stopping the cancel operation if it would put the row in an undesired state, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + event is raised when the Cancel button of a row in edit mode is clicked, but before the row exits edit mode. This enables you to provide an event-handling method that performs a custom routine, such as stopping the cancel operation if it would put the row in an undesired state, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> There is no handler for the event. @@ -3771,25 +3771,25 @@ A that contains event data. Raises the event. - event is raised when a button is clicked in the control. This enables you to provide an event-handling method that performs a custom routine whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - - - -## Examples - A Visual Studio Web site project with source code is available to accompany this topic: [Download](https://go.microsoft.com/fwlink/?LinkId=191882). - - The following example demonstrates how provide an event-handling method for the event. When the Add button is clicked for a given row of the control, the name of the selected customer is added to a control. - + event is raised when a button is clicked in the control. This enables you to provide an event-handling method that performs a custom routine whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + + + +## Examples + A Visual Studio Web site project with source code is available to accompany this topic: [Download](https://go.microsoft.com/fwlink/?LinkId=191882). + + The following example demonstrates how provide an event-handling method for the event. When the Add button is clicked for a given row of the control, the name of the selected customer is added to a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowCommmand/CS/gridviewrowcommandcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCommmand/VB/gridviewrowcommandvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCommmand/VB/gridviewrowcommandvb.aspx" id="Snippet1"::: + ]]> @@ -3822,23 +3822,23 @@ A that contains event data. Raises the event. - control can be rendered, a object must be created for each row in the control. The event is raised when each row in the control is created. This enables you to provide an event-handling method that performs a custom routine, such as adding custom content to a row, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - - - -## Examples - The following example demonstrates how provide an event-handling method for the event. When a row is being created, its index is stored in the property of a control that is contained in the new row. This enables you to determine the index of the row when the user clicks the command button. - + control can be rendered, a object must be created for each row in the control. The event is raised when each row in the control is created. This enables you to provide an event-handling method that performs a custom routine, such as adding custom content to a row, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + + + +## Examples + The following example demonstrates how provide an event-handling method for the event. When a row is being created, its index is stored in the property of a control that is contained in the new row. This enables you to determine the index of the row when the user clicks the command button. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowCreated/CS/gridviewrowcreatedcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCreated/VB/gridviewrowcreatedvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCreated/VB/gridviewrowcreatedvb.aspx" id="Snippet1"::: + ]]> @@ -3873,17 +3873,17 @@ A that contains event data. Raises the event. - control can be rendered, each row in the control must be bound to a record in the data source. The event is raised when a data row (represented by a object) is bound to data in the control. This enables you to provide an event-handling method that performs a custom routine, such as modifying the values of the data bound to the row, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - - A Visual Studio Web site project with source code is available to accompany this topic: [Download](https://go.microsoft.com/fwlink/?LinkId=191882). - + control can be rendered, each row in the control must be bound to a record in the data source. The event is raised when a data row (represented by a object) is bound to data in the control. This enables you to provide an event-handling method that performs a custom routine, such as modifying the values of the data bound to the row, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + + A Visual Studio Web site project with source code is available to accompany this topic: [Download](https://go.microsoft.com/fwlink/?LinkId=191882). + ]]> @@ -3918,15 +3918,15 @@ A that contains event data. Raises the event. - event is raised when a row's Delete button is clicked, but after the control deletes the row. This enables you to provide an event-handling method that performs a custom routine, such as checking the results of the delete operation, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + event is raised when a row's Delete button is clicked, but after the control deletes the row. This enables you to provide an event-handling method that performs a custom routine, such as checking the results of the delete operation, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> @@ -3966,15 +3966,15 @@ A that contains event data. Raises the event. - event is raised when a row's Delete button is clicked, but before the control deletes the row. This enables you to provide an event-handling method that performs a custom routine, such as canceling the delete operation, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + event is raised when a row's Delete button is clicked, but before the control deletes the row. This enables you to provide an event-handling method that performs a custom routine, such as canceling the delete operation, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> There is no handler for the event. @@ -4011,15 +4011,15 @@ A that contains event data. Raises the event. - event is raised when a row's Edit button is clicked, but before the control enters edit mode. This enables you to provide an event-handling method that performs a custom routine, such as canceling the edit operation, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + event is raised when a row's Edit button is clicked, but before the control enters edit mode. This enables you to provide an event-handling method that performs a custom routine, such as canceling the edit operation, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> There is no handler for the event. @@ -4060,15 +4060,15 @@ A that contains event data. Raises the event. - event is raised when a row's Update button is clicked, but after the control updates the row. This enables you to provide an event-handling method that performs a custom routine, such as checking the results of the update operation, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + event is raised when a row's Update button is clicked, but after the control updates the row. This enables you to provide an event-handling method that performs a custom routine, such as checking the results of the update operation, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> @@ -4107,15 +4107,15 @@ A that contains event data. Raises the event. - event is raised when a row's Update button is clicked, but before the control updates the row. This enables you to provide an event-handling method that performs a custom routine, such as canceling the update operation, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + event is raised when a row's Update button is clicked, but before the control updates the row. This enables you to provide an event-handling method that performs a custom routine, such as canceling the update operation, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> There is no handler for the event. @@ -4156,23 +4156,23 @@ An that contains event data. Raises the event. - event is raised when a row's Select button is clicked, but after the control handles the select operation. This enables you to provide an event-handling method that performs a custom routine, such as updating a status label with the currently selected row, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - - - -## Examples - The following example shows how create an event handler for the event. In this example, the selected row is persisted in the view state. So even after a sorting or a paging operation, only that row will be selected. - + event is raised when a row's Select button is clicked, but after the control handles the select operation. This enables you to provide an event-handling method that performs a custom routine, such as updating a status label with the currently selected row, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + + + +## Examples + The following example shows how create an event handler for the event. In this example, the selected row is persisted in the view state. So even after a sorting or a paging operation, only that row will be selected. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.GridView.OnSelectedIndexChanged/CS/Default.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.GridView.OnSelectedIndexChanged/VB/Default.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.GridView.OnSelectedIndexChanged/VB/Default.aspx" id="Snippet1"::: + ]]> @@ -4207,15 +4207,15 @@ A that contains event data. Raises the event. - event is raised when a row's Select button is clicked, but before the control handles the select operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the selection operation, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + event is raised when a row's Select button is clicked, but before the control handles the select operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the selection operation, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> @@ -4251,15 +4251,15 @@ An that contains event data. Raises the event. - event is raised when the hyperlink to sort a column is clicked, but after the control handles the sort operation. This enables you to provide an event-handling method that performs a custom routine, such as custom sorting, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + event is raised when the hyperlink to sort a column is clicked, but after the control handles the sort operation. This enables you to provide an event-handling method that performs a custom routine, such as custom sorting, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> @@ -4296,15 +4296,15 @@ A that contains event data. Raises the event. - event is raised when the hyperlink to sort a column is clicked, but before the control handles the sort operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the sorting operation, whenever this event occurs. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - 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. - + event is raised when the hyperlink to sort a column is clicked, but before the control handles the sort operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the sorting operation, whenever this event occurs. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + 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. + ]]> There is no handler for the event. @@ -4350,19 +4350,19 @@ Gets the number of pages required to display the records of the data source in a control. The number of pages in a control. - property to `true`), use the property to determine the total number of pages required to display the records in the data source. This value is calculated by dividing the total number of records in the data source by the number of records displayed in a page (as specified by the property) and rounding up. - - - -## Examples - The following example demonstrates how to use the property to determine the total number of pages displayed in the control. - + property to `true`), use the property to determine the total number of pages required to display the records in the data source. This value is calculated by dividing the total number of records in the data source by the number of records displayed in a page (as specified by the property) and rounding up. + + + +## Examples + The following example demonstrates how to use the property to determine the total number of pages displayed in the control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewPagerTemplate/CS/gridviewpagertemplatecs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPagerTemplate/VB/gridviewpagertemplatevb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPagerTemplate/VB/gridviewpagertemplatevb.aspx" id="Snippet1"::: + ]]> @@ -4411,19 +4411,19 @@ Gets or sets the index of the currently displayed page. The zero-based index of the currently displayed page. - property to `true`), use the property to determine the index of the currently displayed page. You can also use this property to programmatically change the displayed page. - - - -## Examples - The following example demonstrates how to use the property to determine the index of the currently displayed page in the control. The example also shows how the property can be used to specify which page is displayed after the user selects a value from the pager row. - + property to `true`), use the property to determine the index of the currently displayed page. You can also use this property to programmatically change the displayed page. + + + +## Examples + The following example demonstrates how to use the property to determine the index of the currently displayed page in the control. The example also shows how the property can be used to specify which page is displayed after the user selects a value from the pager row. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewPagerTemplate/CS/gridviewpagertemplatecs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPagerTemplate/VB/gridviewpagertemplatevb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPagerTemplate/VB/gridviewpagertemplatevb.aspx" id="Snippet1"::: + ]]> The property is set to a value less than 0. @@ -4458,23 +4458,23 @@ Occurs when one of the pager buttons is clicked, but after the control handles the paging operation. - event is raised when one of the pager buttons is clicked, but after the control handles the paging operation. This enables you to provide an event-handling method that performs a custom routine, such as a custom paging operation, whenever this event occurs. - - To determine the index of the page selected by the user, use the property of the control. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to display the page number selected by the user from the pager row. - + event is raised when one of the pager buttons is clicked, but after the control handles the paging operation. This enables you to provide an event-handling method that performs a custom routine, such as a custom paging operation, whenever this event occurs. + + To determine the index of the page selected by the user, use the property of the control. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to display the page number selected by the user from the pager row. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewPageIndexChanged/CS/gridviewpageindexchangedcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPageIndexChanged/VB/gridviewpageindexchangedvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPageIndexChanged/VB/gridviewpageindexchangedvb.aspx" id="Snippet1"::: + ]]> @@ -4502,26 +4502,26 @@ Occurs when one of the pager buttons is clicked, but before the control handles the paging operation. - event is raised when one of the pager buttons is clicked, but before the control handles the paging operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the paging operation, whenever this event occurs. - + event is raised when one of the pager buttons is clicked, but before the control handles the paging operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the paging operation, whenever this event occurs. + > [!NOTE] -> This event is not raised when you programmatically set the property. - - A object is passed to the event-handling method, which enables you to determine the index of the page selected by the user and to indicate that the paging operation should be canceled. To cancel the paging operation, set the property of the object to `true`. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to cancel the paging operation if the user attempts to navigate to another page when a control is in edit mode. - +> This event is not raised when you programmatically set the property. + + A object is passed to the event-handling method, which enables you to determine the index of the page selected by the user and to indicate that the paging operation should be canceled. To cancel the paging operation, set the property of the object to `true`. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to cancel the paging operation if the user attempts to navigate to another page when a control is in edit mode. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewPageIndexChanging/CS/gridviewpageindexchangingcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPageIndexChanging/VB/gridviewpageindexchangingvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPageIndexChanging/VB/gridviewpageindexchangingvb.aspx" id="Snippet1"::: + ]]> @@ -4565,25 +4565,25 @@ Gets a reference to the object that enables you to set the properties of the pager buttons in a control. A reference to the that enables you to set the properties of the pager buttons in a control. - property to control the settings of the pager row in a control. The pager row is displayed when the paging feature is enabled (by setting the property to `true`) and contains the controls that allow the user to navigate to the different pages in the control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: - -- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `PagerSettings-Mode`). - -- Nest a `` element between the opening and closing tags of the control. - - The properties can also be set programmatically in the form `Property.Subproperty` (for example, `PagerStyle.Mode`). Common settings usually include the pager row's display mode and custom text or images for the navigation controls. - - - -## Examples - The following example demonstrates how to set the property declaratively. It sets the font and background for the pager row to blue and light blue, respectively. - + property to control the settings of the pager row in a control. The pager row is displayed when the paging feature is enabled (by setting the property to `true`) and contains the controls that allow the user to navigate to the different pages in the control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: + +- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `PagerSettings-Mode`). + +- Nest a `` element between the opening and closing tags of the control. + + The properties can also be set programmatically in the form `Property.Subproperty` (for example, `PagerStyle.Mode`). Common settings usually include the pager row's display mode and custom text or images for the navigation controls. + + + +## Examples + The following example demonstrates how to set the property declaratively. It sets the font and background for the pager row to blue and light blue, respectively. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewAllowPaging/CS/gridviewallowpagingcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowPaging/VB/gridviewallowpagingvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowPaging/VB/gridviewallowpagingvb.aspx" id="Snippet1"::: + ]]> @@ -4632,25 +4632,25 @@ Gets a reference to the object that enables you to set the appearance of the pager row in a control. A reference to the that represents the style of the pager row in a control. - property to control the appearance of the pager row in a control. The pager row is displayed when the paging feature is enabled (by setting the property to `true`) and contains the controls that allow the user to navigate to the different pages in the control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: - -- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `PagerStyle-ForeColor`). - -- Nest a `` element between the opening and closing tags of the control. - - The properties can also be set programmatically in the form `Property.Subproperty` (for example, `PagerStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. - - - -## Examples - The following example demonstrates how to set the property declaratively. It sets the font and background for the pager row to blue and light blue, respectively. - + property to control the appearance of the pager row in a control. The pager row is displayed when the paging feature is enabled (by setting the property to `true`) and contains the controls that allow the user to navigate to the different pages in the control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: + +- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `PagerStyle-ForeColor`). + +- Nest a `` element between the opening and closing tags of the control. + + The properties can also be set programmatically in the form `Property.Subproperty` (for example, `PagerStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. + + + +## Examples + The following example demonstrates how to set the property declaratively. It sets the font and background for the pager row to blue and light blue, respectively. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewAllowPaging/CS/gridviewallowpagingcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowPaging/VB/gridviewallowpagingvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowPaging/VB/gridviewallowpagingvb.aspx" id="Snippet1"::: + ]]> @@ -4718,34 +4718,34 @@ Gets or sets the custom content for the pager row in a control. A that contains the custom content for the pager row. The default value is null, which indicates that this property is not set. - control when the paging feature is enabled (when the property is set to true). The pager row contains the controls that allow the user to navigate to the different pages in the control. Instead of using the built-in pager row user interface (UI), you can define your own UI by using the property. - + control when the paging feature is enabled (when the property is set to true). The pager row contains the controls that allow the user to navigate to the different pages in the control. Instead of using the built-in pager row user interface (UI), you can define your own UI by using the property. + > [!NOTE] -> When the property is set, it overrides the built-in pager row UI. - - To specify a custom template for the pager row, first place `` tags between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing `` tags. To control the appearance of the pager row, use the property. - - Typically, button controls are added to the pager template to perform the paging operations. The control performs a paging operation when a button control with its `CommandName` property set to "Page" is clicked. The button's `CommandArgument` property determines the type of paging operation to perform. The following table lists the command argument values supported by the control. - -|`CommandArgument` value|Description| -|-----------------------------|-----------------| -|"Next"|Navigates to the next page.| -|"Prev"|Navigates to the previous page.| -|"First"|Navigates to the first page.| -|"Last"|Navigates to the last page.| -|Integer value|Navigates to the specified page number.| - - - -## Examples - The following example demonstrates how to create a custom pager template that allows the user to navigate through a control using a control. - +> When the property is set, it overrides the built-in pager row UI. + + To specify a custom template for the pager row, first place `` tags between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing `` tags. To control the appearance of the pager row, use the property. + + Typically, button controls are added to the pager template to perform the paging operations. The control performs a paging operation when a button control with its `CommandName` property set to "Page" is clicked. The button's `CommandArgument` property determines the type of paging operation to perform. The following table lists the command argument values supported by the control. + +|`CommandArgument` value|Description| +|-----------------------------|-----------------| +|`Next`|Navigates to the next page.| +|`Prev`|Navigates to the previous page.| +|`First`|Navigates to the first page.| +|`Last`|Navigates to the last page.| +|Integer value|Navigates to the specified page number.| + + + +## Examples + The following example demonstrates how to create a custom pager template that allows the user to navigate through a control using a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewPagerTemplate/CS/gridviewpagertemplatecs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPagerTemplate/VB/gridviewpagertemplatevb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPagerTemplate/VB/gridviewpagertemplatevb.aspx" id="Snippet1"::: + ]]> @@ -4786,19 +4786,19 @@ Gets or sets the number of records to display on a page in a control. The number of records to display on a single page. The default is 10. - property to `true`), use the property to specify the number of records to display on a single page. - - - -## Examples - The following example demonstrates how to use the property to display 15 records at a time in a control. - + property to `true`), use the property to specify the number of records to display on a single page. + + + +## Examples + The following example demonstrates how to use the property to display 15 records at a time in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewPageSize/CS/gridviewpagesizecs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPageSize/VB/gridviewpagesizevb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewPageSize/VB/gridviewpagesizevb.aspx" id="Snippet1"::: + ]]> The property is set to a value less than 1. @@ -4837,11 +4837,11 @@ An that contains the data source. Binds the specified data source to the control. - method is a helper method called by the control to bind the specified data source to the control. - + method is a helper method called by the control to bind the specified data source to the control. + ]]> @@ -4870,14 +4870,14 @@ Establishes the control hierarchy. - control. - + control. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> @@ -4905,11 +4905,11 @@ The argument to pass to the event handler. Creates the arguments for the callback handler in the method. - method is a helper method used by the control to create the arguments for the callback handler in the method. - + method is a helper method used by the control to create the arguments for the callback handler in the method. + ]]> @@ -4938,14 +4938,14 @@ The event argument from which to create a for the event or events that are raised. Raises the appropriate events for the control when it posts back to the server. - method when a postback event occurs that raises the appropriate events for a control. This call occurs in the page life cycle after loading and change notification are complete, but before prerendering occurs. This method has been implemented to create a object for the events that are raised. - + method when a postback event occurs that raises the appropriate events for a control. This call occurs in the page life cycle after loading and change notification are complete, but before prerendering occurs. This method has been implemented to create a object for the events that are raised. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> @@ -4976,14 +4976,14 @@ The used to render the server control content on the client's browser. Renders the Web server control content to the client's browser using the specified object. - method is used to render the server control content to the client's browser using the specified object. - + method is used to render the server control content to the client's browser using the specified object. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> @@ -5008,28 +5008,28 @@ Occurs when the Cancel button of a row in edit mode is clicked, but before the row exits edit mode. - event is raised when the Cancel button of a row in edit mode is clicked, but before the row exits edit mode. This enables you to provide an event-handling method that performs a custom routine, such as stopping the cancel operation if it would put the row in an undesired state, whenever this event occurs. - - A object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the cancel operation should be stopped. To stop the cancel operation, set the property of the object to `true`. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to display a cancellation message when the user cancels the update operation of a control. - + event is raised when the Cancel button of a row in edit mode is clicked, but before the row exits edit mode. This enables you to provide an event-handling method that performs a custom routine, such as stopping the cancel operation if it would put the row in an undesired state, whenever this event occurs. + + A object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the cancel operation should be stopped. To stop the cancel operation, set the property of the object to `true`. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to display a cancellation message when the user cancels the update operation of a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowCancellingEdit/CS/gridviewrowcancellingeditcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCancellingEdit/VB/gridviewrowcancellingeditvb.aspx" id="Snippet1"::: - - The following example demonstrates how to use the event to cancel the update operation when the data source is set programmatically. - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCancellingEdit/VB/gridviewrowcancellingeditvb.aspx" id="Snippet1"::: + + The following example demonstrates how to use the event to cancel the update operation when the data source is set programmatically. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowEditing/CS/GridViewRowEditing2CS.aspx" id="Snippet2"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowEditing/VB/GridViewRowEditing2VB.aspx" id="Snippet2"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowEditing/VB/GridViewRowEditing2VB.aspx" id="Snippet2"::: + ]]> @@ -5062,47 +5062,45 @@ Occurs when a button is clicked in a control. - event is raised when a button is clicked in the control. This enables you to provide an event-handling method that performs a custom routine whenever this event occurs. - - Buttons within a control can also invoke some of the built-in functionality of the control. To perform one of these operations, set the `CommandName` property of a button to one of the values in the following table. - -|`CommandName` value|Description| -|-------------------------|-----------------| -|"Cancel"|Cancels an edit operation and returns the control to read-only mode. Raises the event.| -|"Delete"|Deletes the current record. Raises the and events.| -|"Edit"|Puts the current record in edit mode. Raises the event.| -|"Page"|Performs a paging operation. Sets the `CommandArgument` property of the button to "First", "Last", "Next", "Prev", or a page number to specify the type of paging operation to perform. Raises the and events.| -|"Select"|Selects the current record. Raises the and events.| -|"Sort"|Sorts the control. Raises the and events.| -|"Update"|Updates the current record in the data source. Raises the and events.| - - Although the event is raised when a button listed in the previous table is clicked, it is recommended that you use the events listed in the table for the operation. - - A object is passed to the event-handling method, which enables you to determine the command name and command argument of the button clicked. - + event is raised when a button is clicked in the control. This enables you to provide an event-handling method that performs a custom routine whenever this event occurs. + + Buttons within a control can also invoke some of the built-in functionality of the control. To perform one of these operations, set the `CommandName` property of a button to one of the values in the following table. + +|`CommandName` value|Description| +|-------------------------|-----------------| +|`Cancel`|Cancels an edit operation and returns the control to read-only mode. Raises the event.| +|`Delete`|Deletes the current record. Raises the and events.| +|`Edit`|Puts the current record in edit mode. Raises the event.| +|`Page`|Performs a paging operation. Sets the `CommandArgument` property of the button to "First", "Last", "Next", "Prev", or a page number to specify the type of paging operation to perform. Raises the and events.| +|`Select`|Selects the current record. Raises the and events.| +|`Sort`|Sorts the control. Raises the and events.| +|`Update`|Updates the current record in the data source. Raises the and events.| + + Although the event is raised when a button listed in the previous table is clicked, it is recommended that you use the events listed in the table for the operation. + + A object is passed to the event-handling method, which enables you to determine the command name and command argument of the button clicked. + > [!NOTE] -> To determine the index of the row that raised the event, use the property of the event argument that is passed to the event. The class automatically populates the property with the appropriate index value. For other command buttons, you must manually set the property of the command button. For example, you can set the to `<%# Container.DataItemIndex %>` when the control has no paging enabled. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - A Visual Studio Web site project with source code is available to accompany this topic: [Download](https://go.microsoft.com/fwlink/?LinkId=191882). - - The following example demonstrates how to use the event to add the name of a customer from a control to a control when a row's Add button is clicked. - +> To determine the index of the row that raised the event, use the property of the event argument that is passed to the event. The class automatically populates the property with the appropriate index value. For other command buttons, you must manually set the property of the command button. For example, you can set the to `<%# Container.DataItemIndex %>` when the control has no paging enabled. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + +## Examples + A Visual Studio Web site project with source code is available to accompany this topic: [Download](https://go.microsoft.com/fwlink/?LinkId=191882). + + The following example demonstrates how to use the event to add the name of a customer from a control to a control when a row's Add button is clicked. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowCommmand/CS/gridviewrowcommandcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCommmand/VB/gridviewrowcommandvb.aspx" id="Snippet1"::: - - The following example demonstrates how to use the event to update the price of a product when a row's button is clicked. This example has the paging functionality enabled for the control and sets the property of the control to the appropriate row index. - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCommmand/VB/gridviewrowcommandvb.aspx" id="Snippet1"::: + + The following example demonstrates how to use the event to update the price of a product when a row's button is clicked. This example has the paging functionality enabled for the control and sets the property of the control to the appropriate row index. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowCommmand/CS/gridviewrowcommand2cs.aspx" id="Snippet2"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCommmand/VB/gridviewrowcommand2vb.aspx" id="Snippet2"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCommmand/VB/gridviewrowcommand2vb.aspx" id="Snippet2"::: + ]]> @@ -5128,23 +5126,23 @@ Occurs when a row is created in a control. - control can be rendered, a object must be created for each row in the control. The event is raised when each row in the control is created. This enables you to provide an event-handling method that performs a custom routine, such as adding custom content to a row, whenever this event occurs. - - A object is passed to the event-handling method, which enables you to access the properties of the row being created. To access a specific cell in the row, use the property of the object. You can determine which row type (header row, data row, and so on) is being created by using the property. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to store the index of the row being created in the property of a control contained in the row. This enables you to determine the index of the row that contains the control when the user clicked the button. - + control can be rendered, a object must be created for each row in the control. The event is raised when each row in the control is created. This enables you to provide an event-handling method that performs a custom routine, such as adding custom content to a row, whenever this event occurs. + + A object is passed to the event-handling method, which enables you to access the properties of the row being created. To access a specific cell in the row, use the property of the object. You can determine which row type (header row, data row, and so on) is being created by using the property. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to store the index of the row being created in the property of a control contained in the row. This enables you to determine the index of the row that contains the control when the user clicked the button. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowCreated/CS/gridviewrowcreatedcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCreated/VB/gridviewrowcreatedvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowCreated/VB/gridviewrowcreatedvb.aspx" id="Snippet1"::: + ]]> @@ -5172,25 +5170,25 @@ Occurs when a data row is bound to data in a control. - control can be rendered, each row in the control must be bound to a record in the data source. The event is raised when a data row (represented by a object) is bound to data in the control. This enables you to provide an event-handling method that performs a custom routine, such as modifying the values of the data bound to the row, whenever this event occurs. - - A object is passed to the event-handling method, which enables you to access the properties of the row being bound. To access a specific cell in the row, use the property of the object contained in the property of the object. You can determine which row type (header row, data row, and so on) is being bound by using the property. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - A Visual Studio Web site project with source code is available to accompany this topic: [Download](https://go.microsoft.com/fwlink/?LinkId=191882). - - The following example demonstrates how to use the event to modify the value of a field in the data source before it is displayed in a control. - + control can be rendered, each row in the control must be bound to a record in the data source. The event is raised when a data row (represented by a object) is bound to data in the control. This enables you to provide an event-handling method that performs a custom routine, such as modifying the values of the data bound to the row, whenever this event occurs. + + A object is passed to the event-handling method, which enables you to access the properties of the row being bound. To access a specific cell in the row, use the property of the object contained in the property of the object. You can determine which row type (header row, data row, and so on) is being bound by using the property. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + A Visual Studio Web site project with source code is available to accompany this topic: [Download](https://go.microsoft.com/fwlink/?LinkId=191882). + + The following example demonstrates how to use the event to modify the value of a field in the data source before it is displayed in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowDataBound/CS/gridviewrowdataboundcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowDataBound/VB/gridviewrowdataboundvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowDataBound/VB/gridviewrowdataboundvb.aspx" id="Snippet1"::: + ]]> @@ -5218,23 +5216,23 @@ Occurs when a row's Delete button is clicked, but after the control deletes the row. - event is raised when a row's Delete button is clicked, but after the control deletes the row. This enables you to provide an event-handling method that performs a custom routine, such as checking the results of the delete operation, whenever this event occurs. - - A object is passed to the event-handling method, which enables you to determine the number of rows affected and any exceptions that might have occurred. You can also indicate whether the exception was handled in the event-handling method by setting the property of the object. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to check the result of the delete operation. A message is displayed to indicate to the user whether the operation succeeded. - + event is raised when a row's Delete button is clicked, but after the control deletes the row. This enables you to provide an event-handling method that performs a custom routine, such as checking the results of the delete operation, whenever this event occurs. + + A object is passed to the event-handling method, which enables you to determine the number of rows affected and any exceptions that might have occurred. You can also indicate whether the exception was handled in the event-handling method by setting the property of the object. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to check the result of the delete operation. A message is displayed to indicate to the user whether the operation succeeded. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowDeleted/CS/gridviewrowdeletedcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowDeleted/VB/gridviewrowdeletedvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowDeleted/VB/gridviewrowdeletedvb.aspx" id="Snippet1"::: + ]]> @@ -5267,29 +5265,29 @@ Occurs when a row's Delete button is clicked, but before the control deletes the row. - event is raised when a row's Delete button is clicked, but before the control deletes the row. This enables you to provide an event-handling method that performs a custom routine, such as canceling the delete operation, whenever this event occurs. - - A object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the delete operation should be canceled. To cancel the delete operation, set the property of the object to `true`. You can also manipulate the and collections, if necessary, before the values are passed to the data source. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to cancel the delete operation. The page contains a control that displays a list of customer names and addresses from the AdventureWorksLT database. When the user clicks the **Delete** link for a row, the handler for the event checks the last name of the person displayed in the row that the user is trying to delete. If the last name is "Beaver", the delete operation is canceled, and an error message is displayed. For any other name, the delete operation proceeds and the row is deleted. - - The event handler uses the property of the object to find the row that the user is trying to delete. The example examines the contents of the collection. If the value you want to compare to is a key value, you could examine the collection instead. - - Rows are deleted from the CustomerAddress table instead of the Customer table in order to keep the example simple. The control shows the result of joining three tables: Customer, Address, and CustomerAddress. When a CustomerAddress row is deleted, the corresponding row disappears. Referential integrity constraints would make the code for an example that actually deletes rows from the Customer table more complex. - - For information about how to set up the AdventureWorksLT database, see [How to: Set Up an AdventureWorksLT Sample Database for ASP.NET Development](https://msdn.microsoft.com/library/2baad633-9d63-49cc-a6b2-917cafd35356). - + event is raised when a row's Delete button is clicked, but before the control deletes the row. This enables you to provide an event-handling method that performs a custom routine, such as canceling the delete operation, whenever this event occurs. + + A object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the delete operation should be canceled. To cancel the delete operation, set the property of the object to `true`. You can also manipulate the and collections, if necessary, before the values are passed to the data source. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to cancel the delete operation. The page contains a control that displays a list of customer names and addresses from the AdventureWorksLT database. When the user clicks the **Delete** link for a row, the handler for the event checks the last name of the person displayed in the row that the user is trying to delete. If the last name is "Beaver", the delete operation is canceled, and an error message is displayed. For any other name, the delete operation proceeds and the row is deleted. + + The event handler uses the property of the object to find the row that the user is trying to delete. The example examines the contents of the collection. If the value you want to compare to is a key value, you could examine the collection instead. + + Rows are deleted from the CustomerAddress table instead of the Customer table in order to keep the example simple. The control shows the result of joining three tables: Customer, Address, and CustomerAddress. When a CustomerAddress row is deleted, the corresponding row disappears. Referential integrity constraints would make the code for an example that actually deletes rows from the Customer table more complex. + + For information about how to set up the AdventureWorksLT database, see [How to: Set Up an AdventureWorksLT Sample Database for ASP.NET Development](https://msdn.microsoft.com/library/2baad633-9d63-49cc-a6b2-917cafd35356). + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowDeleting/CS/gridviewrowdeleting.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowDeleting/VB/gridviewrowdeleting.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowDeleting/VB/gridviewrowdeleting.aspx" id="Snippet1"::: + ]]> @@ -5318,28 +5316,28 @@ Occurs when a row's Edit button is clicked, but before the control enters edit mode. - event is raised when a row's Edit button is clicked, but before the control enters edit mode. This enables you to provide an event-handling method that performs a custom routine, such as canceling the edit operation, whenever this event occurs. - - A object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the edit operation should be canceled. To cancel the edit operation, set the property of the object to `true`. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to put a row in edit mode when the data source is set programmatically. - + event is raised when a row's Edit button is clicked, but before the control enters edit mode. This enables you to provide an event-handling method that performs a custom routine, such as canceling the edit operation, whenever this event occurs. + + A object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the edit operation should be canceled. To cancel the edit operation, set the property of the object to `true`. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to put a row in edit mode when the data source is set programmatically. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowEditing/CS/GridViewRowEditing2CS.aspx" id="Snippet2"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowEditing/VB/GridViewRowEditing2VB.aspx" id="Snippet2"::: - - The following example demonstrates how to use the event to cancel the editing operation if the user attempts to edit the record for a company in the United States. - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowEditing/VB/GridViewRowEditing2VB.aspx" id="Snippet2"::: + + The following example demonstrates how to use the event to cancel the editing operation if the user attempts to edit the record for a company in the United States. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowEditing/CS/gridviewroweditingcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowEditing/VB/gridviewroweditingvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowEditing/VB/gridviewroweditingvb.aspx" id="Snippet1"::: + ]]> @@ -5387,27 +5385,27 @@ Gets or sets the name of the column to use as the column header for the control. This property is provided to make the control more accessible to users of assistive technology devices. The name of the column to use as the column header. The default is an empty string (""), which indicates that this property is not set. - ` elements. The control has a built-in header row that can be displayed by setting the property to `true`. You can also optionally specify a header column (usually the first or last column in the control) by setting this property. When this property is set, all cells in the column that corresponds to the specified field name are rendered as `` elements. - + ` elements. The control has a built-in header row that can be displayed by setting the property to `true`. You can also optionally specify a header column (usually the first or last column in the control) by setting this property. When this property is set, all cells in the column that corresponds to the specified field name are rendered as `` elements. + > [!NOTE] -> Although the specified column is treated like a header, the , , and properties do not apply to the header column. - - The default rendering of the `` element is preserved, rendering text as bold and centered horizontally. Developers can override the behavior of the `` element using a cascading style sheet. - +> Although the specified column is treated like a header, the , , and properties do not apply to the header column. + + The default rendering of the `` element is preserved, rendering text as bold and centered horizontally. Developers can override the behavior of the `` element using a cascading style sheet. + > [!NOTE] -> This property works only with bound fields. It does not work with template fields. - - - -## Examples - The following example demonstrates how to use the property to display a header column in a control. - +> This property works only with bound fields. It does not work with template fields. + + + +## Examples + The following example demonstrates how to use the property to display a header column in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/gridviewrowheadercolumn/CS/GridViewRowHeaderColumncs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewrowheadercolumn/VB/GridViewRowHeaderColumnvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewrowheadercolumn/VB/GridViewRowHeaderColumnvb.aspx" id="Snippet1"::: + ]]> @@ -5445,22 +5443,22 @@ Gets a collection of objects that represent the data rows in a control. A that contains all the data rows in a control. - property (collection) is used to store the data rows in a control. The control automatically populates the collection by creating a object for each record in the data source and then adding each object to the collection. This property is commonly used to access a specific row in the control or to iterate though the entire collection of rows. - + property (collection) is used to store the data rows in a control. The control automatically populates the collection by creating a object for each record in the data source and then adding each object to the collection. This property is commonly used to access a specific row in the control or to iterate though the entire collection of rows. + > [!NOTE] -> Only rows with their property set to `DataControlRowType.DataRow` are stored in the collection. The objects that represent the header, footer, and pager rows are not included in the collection. - - - -## Examples - The following example demonstrates how to use the collection to access the row being edited in a control. After a row is updated, a message is displayed to indicate that the update was successful. - +> Only rows with their property set to `DataControlRowType.DataRow` are stored in the collection. The objects that represent the header, footer, and pager rows are not included in the collection. + + + +## Examples + The following example demonstrates how to use the collection to access the row being edited in a control. After a row is updated, a message is displayed to indicate that the update was successful. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRows/CS/gridviewrowscs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRows/VB/gridviewrowsvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRows/VB/gridviewrowsvb.aspx" id="Snippet1"::: + ]]> @@ -5501,25 +5499,25 @@ Gets a reference to the object that enables you to set the appearance of the data rows in a control. A reference to the that represents the style of the data rows in a control. - property to control the appearance of the data rows in a control. When the property is also set, the data rows are displayed alternating between the settings and the settings. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: - -- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `RowStyle-ForeColor`). - -- Nest a `` element between the opening and closing tags of the control. - - The properties can also be set programmatically in the form `Property.Subproperty` (for example, `RowStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. - - - -## Examples - The following example demonstrates how to use the property to declaratively define the style for the item rows in a control. - + property to control the appearance of the data rows in a control. When the property is also set, the data rows are displayed alternating between the settings and the settings. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: + +- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `RowStyle-ForeColor`). + +- Nest a `` element between the opening and closing tags of the control. + + The properties can also be set programmatically in the form `Property.Subproperty` (for example, `RowStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. + + + +## Examples + The following example demonstrates how to use the property to declaratively define the style for the item rows in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowStyle/CS/gridviewrowstylecs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowStyle/VB/gridviewrowstylevb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowStyle/VB/gridviewrowstylevb.aspx" id="Snippet1"::: + ]]> @@ -5551,23 +5549,23 @@ Occurs when a row's Update button is clicked, but after the control updates the row. - event is raised when a row's Update button is clicked, but after the control updates the row. This enables you to provide an event-handling method that performs a custom routine, such as checking the results of the update operation, whenever this event occurs. - - A object is passed to the event-handling method, which enables you to determine the number of rows affected and any exceptions that might have occurred. You can also indicate whether the exception was handled in the event-handling method by setting the property of the object. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to check the result of the update operation. A message is displayed to indicate to the user whether the operation succeeded. - + event is raised when a row's Update button is clicked, but after the control updates the row. This enables you to provide an event-handling method that performs a custom routine, such as checking the results of the update operation, whenever this event occurs. + + A object is passed to the event-handling method, which enables you to determine the number of rows affected and any exceptions that might have occurred. You can also indicate whether the exception was handled in the event-handling method by setting the property of the object. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to check the result of the update operation. A message is displayed to indicate to the user whether the operation succeeded. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowUpdated/CS/gridviewrowupdatedcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowUpdated/VB/gridviewrowupdatedvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowUpdated/VB/gridviewrowupdatedvb.aspx" id="Snippet1"::: + ]]> @@ -5604,26 +5602,26 @@ Occurs when a row's Update button is clicked, but before the control updates the row. - event is raised when a row's Update button is clicked, but before the control updates the row. This enables you to provide an event-handling method that performs a custom routine, such as canceling the update operation, whenever this event occurs. - - A object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the update operation should be canceled. To cancel the update operation, set the property of the object to `true`. You can also manipulate the , , and collections, if necessary, before the values are passed to the data source. A common way to use these collections is to HTML-encode the values supplied by the user before they are stored in the data source. This helps to prevent script injection attacks. - + event is raised when a row's Update button is clicked, but before the control updates the row. This enables you to provide an event-handling method that performs a custom routine, such as canceling the update operation, whenever this event occurs. + + A object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the update operation should be canceled. To cancel the update operation, set the property of the object to `true`. You can also manipulate the , , and collections, if necessary, before the values are passed to the data source. A common way to use these collections is to HTML-encode the values supplied by the user before they are stored in the data source. This helps to prevent script injection attacks. + > [!NOTE] -> The , and collections are automatically populated only when the control is bound to data by using the property. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to update the values in the data source object when the data source is set programmatically. - +> The , and collections are automatically populated only when the control is bound to data by using the property. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to update the values in the data source object when the data source is set programmatically. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewRowEditing/CS/GridViewRowEditing2CS.aspx" id="Snippet2"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowEditing/VB/GridViewRowEditing2VB.aspx" id="Snippet2"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewRowEditing/VB/GridViewRowEditing2VB.aspx" id="Snippet2"::: + ]]> @@ -5658,14 +5656,14 @@ Saves the state of the properties in the control that need to be persisted, even when the property is set to . Returns the server control's current view state. If there is no view state associated with the control, this method returns . - control that need to be persisted, even when the property is set to `false`. - + control that need to be persisted, even when the property is set to `false`. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> @@ -5724,29 +5722,29 @@ Gets the object that contains the data key value for the selected row in a control. The for the selected row in a control. The default is , which indicates that no row is currently selected. - property is set, the control automatically creates a object for each row in the control using the value or values of the specified field or fields. The objects are then added to the control's collection. Normally, the property is used to retrieve the object for a specific data row in the control. However, if you just need to retrieve the object of the currently selected row, you can simply use the property as a shortcut. - + property is set, the control automatically creates a object for each row in the control using the value or values of the specified field or fields. The objects are then added to the control's collection. Normally, the property is used to retrieve the object for a specific data row in the control. However, if you just need to retrieve the object of the currently selected row, you can simply use the property as a shortcut. + > [!NOTE] -> This is the same as retrieving the object at the index specified by the property from the collection. You can also use the property to retrieve the data key value for the currently selected row directly. - - If you are creating a object and want to access a key field other than the first field, use the indexed property in the property of the object. An example is shown below. - - - -## Examples - The following example demonstrates how to use the property to determine the data key value of the selected row in a control. - +> This is the same as retrieving the object at the index specified by the property from the collection. You can also use the property to retrieve the data key value for the currently selected row directly. + + If you are creating a object and want to access a key field other than the first field, use the indexed property in the property of the object. An example is shown below. + + + +## Examples + The following example demonstrates how to use the property to determine the data key value of the selected row in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSelectedDataKey/CS/gridviewselecteddatakeycs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelectedDataKey/VB/gridviewselecteddatakeyvb.aspx" id="Snippet1"::: - - The following example demonstrates how to use the second key field as a parameter in a master/detail scenario. A control is used to display records from the Order Details table of the Northwind database. When a record is selected in the control, the details of the product from the Products table are displayed in a control. ProductID is the second key name in the control. To access the second key, the value of GridView1.SelectedDataKey[1] is used as the for the object of the control of the control. - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelectedDataKey/VB/gridviewselecteddatakeyvb.aspx" id="Snippet1"::: + + The following example demonstrates how to use the second key field as a parameter in a master/detail scenario. A control is used to display records from the Order Details table of the Northwind database. When a record is selected in the control, the details of the product from the Products table are displayed in a control. ProductID is the second key name in the control. To access the second key, the value of GridView1.SelectedDataKey[1] is used as the for the object of the control of the control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSelectedDataKeyIndex/CS/gridviewselecteddatakeycs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelectedDataKeyIndex/VB/gridviewselecteddatakeyvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelectedDataKeyIndex/VB/gridviewselecteddatakeyvb.aspx" id="Snippet1"::: + ]]> No data keys are specified in the property. @@ -5790,19 +5788,19 @@ Gets or sets the index of the selected row in a control. The zero-based index of the selected row in a control. The default is -1, which indicates that no row is currently selected. - property to determine the index of the currently selected row in a control. You can also use this property to programmatically select a row in the control. To clear the selection of a row, set this property to -1. The appearance of the currently selected row can be customized by using the property. To access the currently selected row, use the property. - - - -## Examples - The following example demonstrates how to use the property to select the second row in a control when the control is initially displayed. - + property to determine the index of the currently selected row in a control. You can also use this property to programmatically select a row in the control. To clear the selection of a row, set this property to -1. The appearance of the currently selected row can be customized by using the property. To access the currently selected row, use the property. + + + +## Examples + The following example demonstrates how to use the property to select the second row in a control when the control is initially displayed. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSelect/CS/gridviewselectcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: + ]]> The property is set to a value less than -1. @@ -5831,21 +5829,21 @@ Occurs when a row's Select button is clicked, but after the control handles the select operation. - event is raised when a row's Select button is clicked, but after the control handles the select operation. This enables you to provide an event-handling method that performs a custom routine, such as updating a status label with the currently selected row, whenever this event occurs. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to display the name of the customer in the selected row of the control. - + event is raised when a row's Select button is clicked, but after the control handles the select operation. This enables you to provide an event-handling method that performs a custom routine, such as updating a status label with the currently selected row, whenever this event occurs. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to display the name of the customer in the selected row of the control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSelect/CS/gridviewselectcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: + ]]> @@ -5873,26 +5871,26 @@ Occurs when a row's Select button is clicked, but before the control handles the select operation. - event is raised when a row's Select button is clicked, but before the control handles the select operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the selection operation, whenever this event occurs. - + event is raised when a row's Select button is clicked, but before the control handles the select operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the selection operation, whenever this event occurs. + > [!NOTE] -> This event is not raised when you programmatically set the property. - - A object is passed to the event-handling method, which enables you to determine the index of the row selected by the user and to indicate that the selection operation should be canceled. To cancel the selection operation, set the property of the object to `true`. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to cancel a select operation. - +> This event is not raised when you programmatically set the property. + + A object is passed to the event-handling method, which enables you to determine the index of the row selected by the user and to indicate that the selection operation should be canceled. To cancel the selection operation, set the property of the object to `true`. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to cancel a select operation. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSelect/CS/gridviewselectcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: + ]]> @@ -5968,24 +5966,24 @@ Gets a reference to a object that represents the selected row in the control. A that represents the selected row in the control, or `null` if nothing is selected. - control, use the property to retrieve the object that represents that row. - + control, use the property to retrieve the object that represents that row. + > [!NOTE] -> This is the same as retrieving the object at the index specified by the property from the collection. - - This object can then be used to access the properties of the selected row. - - - -## Examples - The following example demonstrates how to use the property to access the properties of the object that represents the selected row in the control. - +> This is the same as retrieving the object at the index specified by the property from the collection. + + This object can then be used to access the properties of the selected row. + + + +## Examples + The following example demonstrates how to use the property to access the properties of the object that represents the selected row in the control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSelect/CS/gridviewselectcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: + ]]> @@ -6028,25 +6026,25 @@ Gets a reference to the object that enables you to set the appearance of the selected row in a control. A reference to the that represents the style of the selected row in a control. - property to control the appearance of the selected row in a control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: - -- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `SelectedRowStyle-ForeColor`). - -- Nest a `` element between the opening and closing tags of the control. - - The properties can also be set programmatically in the form `Property.Subproperty` (for example, `SelectedRowStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. - - - -## Examples - The following example demonstrates how to use the property to define a custom style for the selected row in a control. - + property to control the appearance of the selected row in a control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods: + +- Place an attribute in the opening tag of the control in the form `Property-Subproperty`, where `Subproperty` is a property of the object (for example, `SelectedRowStyle-ForeColor`). + +- Nest a `` element between the opening and closing tags of the control. + + The properties can also be set programmatically in the form `Property.Subproperty` (for example, `SelectedRowStyle.ForeColor`). Common settings usually include a custom background color, foreground color, and font properties. + + + +## Examples + The following example demonstrates how to use the property to define a custom style for the selected row in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSelect/CS/gridviewselectcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelect/VB/gridviewselectvb.aspx" id="Snippet1"::: + ]]> @@ -6085,21 +6083,21 @@ Gets the data key value of the selected row in a control. The data key value of the selected row in a control. - property is set with a comma-separated list of field names that represent the primary key of the data source, the control automatically creates a object for each row in the control using the value or values of the specified field or fields. The objects are then added to the control's collection. Normally, the property is used to retrieve the object for a specific data row in the control. However, if you just need to retrieve the object of the currently selected row, you can simply use the property as a shortcut. As a further shortcut, you can directly determine the data key value of the first key field of the selected row by using the property. - - If you are creating a object and want to access a key field other than the first field, use the property. For an example, see . - - - -## Examples - The following example demonstrates how to use the property to determine the data key value of the selected row in a control. - + property is set with a comma-separated list of field names that represent the primary key of the data source, the control automatically creates a object for each row in the control using the value or values of the specified field or fields. The objects are then added to the control's collection. Normally, the property is used to retrieve the object for a specific data row in the control. However, if you just need to retrieve the object of the currently selected row, you can simply use the property as a shortcut. As a further shortcut, you can directly determine the data key value of the first key field of the selected row by using the property. + + If you are creating a object and want to access a key field other than the first field, use the property. For an example, see . + + + +## Examples + The following example demonstrates how to use the property to determine the data key value of the selected row in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSelectedValue/CS/gridviewselectedvaluecs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelectedValue/VB/gridviewselectedvaluevb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSelectedValue/VB/gridviewselectedvaluevb.aspx" id="Snippet1"::: + ]]> @@ -6136,11 +6134,11 @@ The index of the row to edit. Selects the row to edit in a control. - event. - + event. + ]]> @@ -6173,11 +6171,11 @@ The index of the row to edit. Puts a row in edit mode in a control by using the specified row index. - event. - + event. + ]]> @@ -6210,11 +6208,11 @@ The index of the row on the page to edit. Sets the page index of the control by using the row index. - event. - + event. + ]]> @@ -6246,19 +6244,19 @@ to display the footer row; otherwise, . The default is . - property to specify whether a control displays the footer row. To control the appearance of the footer row, use the property. - - - -## Examples - The following example demonstrates how to use the property to display the footer row in a control. - + property to specify whether a control displays the footer row. To control the appearance of the footer row, use the property. + + + +## Examples + The following example demonstrates how to use the property to display the footer row in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewShowHeader/CS/gridviewshowheadercs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewShowHeader/VB/gridviewshowheadervb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewShowHeader/VB/gridviewshowheadervb.aspx" id="Snippet1"::: + ]]> @@ -6292,19 +6290,19 @@ to display the header row; otherwise, . The default is . - property to specify whether a control displays the header row. To control the appearance of the header row, use the property. - - - -## Examples - The following example demonstrates how to use the property to display the header row in a control. - + property to specify whether a control displays the header row. To control the appearance of the header row, use the property. + + + +## Examples + The following example demonstrates how to use the property to display the header row in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewShowHeader/CS/gridviewshowheadercs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewShowHeader/VB/gridviewshowheadervb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewShowHeader/VB/gridviewshowheadervb.aspx" id="Snippet1"::: + ]]> @@ -6370,19 +6368,19 @@ One of the values. Sorts the control based on the specified sort expression and direction. - method to programmatically sort the control using the specified sort expression and direction. The sort expression specifies the column or columns with which to sort. To sort multiple columns, create a sort expression that contains a comma-separated list of field names. The sort direction indicates whether sorting is performed in ascending or descending order. This method is commonly used when you need to sort the control from outside of the control, such as from a different control on the page. This method is also commonly used to programmatically set a default sort order for the control when it is first rendered. Calling this method also raises the and events. - - - -## Examples - The following example demonstrates how to use the method to programmatically sort the control by multiple columns. - + method to programmatically sort the control using the specified sort expression and direction. The sort expression specifies the column or columns with which to sort. To sort multiple columns, create a sort expression that contains a comma-separated list of field names. The sort direction indicates whether sorting is performed in ascending or descending order. This method is commonly used when you need to sort the control from outside of the control, such as from a different control on the page. This method is also commonly used to programmatically set a default sort order for the control when it is first rendered. Calling this method also raises the and events. + + + +## Examples + The following example demonstrates how to use the method to programmatically sort the control by multiple columns. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSort/CS/GridViewSortcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSort/VB/GridViewSortvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSort/VB/GridViewSortvb.aspx" id="Snippet1"::: + ]]> The control is bound to a data source control, but the that is associated with the data source is . @@ -6437,22 +6435,22 @@ Gets the sort direction of the column being sorted. One of the values. The default is . - property to determine whether the column being sorted is sorted in ascending or descending order. - + property to determine whether the column being sorted is sorted in ascending or descending order. + > [!NOTE] -> The control has a built-in sorting feature that automatically sets this property. This property is typically used only when you need to programmatically determine the sort direction or when you are adding your own custom sorting functionality to a control. - - - -## Examples - The following example demonstrates how to use the property to programmatically determine the sort direction of a control. - +> The control has a built-in sorting feature that automatically sets this property. This property is typically used only when you need to programmatically determine the sort direction or when you are adding your own custom sorting functionality to a control. + + + +## Examples + The following example demonstrates how to use the property to programmatically determine the sort direction of a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/gridviewfooterrow/CS/gridviewfooterrowcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewfooterrow/VB/gridviewfooterrowvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/gridviewfooterrow/VB/gridviewfooterrowvb.aspx" id="Snippet1"::: + ]]> @@ -6479,21 +6477,21 @@ Occurs when the hyperlink to sort a column is clicked, but after the control handles the sort operation. - event is raised when the hyperlink to sort a column is clicked, but after the control handles the sort operation. This enables you to provide an event-handling method that performs a custom routine, such as custom sorting, whenever this event occurs. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to display the name of the column being sorted. - + event is raised when the hyperlink to sort a column is clicked, but after the control handles the sort operation. This enables you to provide an event-handling method that performs a custom routine, such as custom sorting, whenever this event occurs. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to display the name of the column being sorted. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSorting/CS/gridviewsortingcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSorting/VB/gridviewsortingvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSorting/VB/gridviewsortingvb.aspx" id="Snippet1"::: + ]]> @@ -6538,11 +6536,11 @@ if a style is applied to the control when the column is sorted in ascending order; otherwise, . - @@ -6581,11 +6579,11 @@ if a style is applied to the heading when the column is sorted in ascending order; otherwise, . - @@ -6624,11 +6622,11 @@ if a style is applied to the when the column is sorted in descending order; otherwise, . - @@ -6667,11 +6665,11 @@ if a style is applied to the heading when the column is sorted in descending order; otherwise, . - @@ -6710,24 +6708,24 @@ Gets the sort expression associated with the column or columns being sorted. The sort expression associated with the column or columns being sorted. - property to determine the sort expression associated with the column or columns being sorted. - + property to determine the sort expression associated with the column or columns being sorted. + > [!NOTE] -> The control has a built-in sorting feature that automatically sets this property. This property is typically used only when you need to programmatically determine the column or columns being sorted or when you are adding your own custom sorting functionality to a control. - - When multiple columns are sorted, this property contains a comma-separated list of the fields by which to sort. - - - -## Examples - The following example demonstrates how to use the property to determine the name of the column being sorted. - +> The control has a built-in sorting feature that automatically sets this property. This property is typically used only when you need to programmatically determine the column or columns being sorted or when you are adding your own custom sorting functionality to a control. + + When multiple columns are sorted, this property contains a comma-separated list of the fields by which to sort. + + + +## Examples + The following example demonstrates how to use the property to determine the name of the column being sorted. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewAllowSortingColumns/CS/GridViewAllowSortingColumnscs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowSortingColumns/VB/GridViewAllowSortingColumnsvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewAllowSortingColumns/VB/GridViewAllowSortingColumnsvb.aspx" id="Snippet1"::: + ]]> @@ -6753,30 +6751,30 @@ Occurs when the hyperlink to sort a column is clicked, but before the control handles the sort operation. - event is raised when the hyperlink to sort a column is clicked, but before the control handles the sort operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the sorting operation, whenever this event occurs. - - A object is passed to the event-handling method, which enables you to determine the sort expression for the column and to indicate that the selection operation should be canceled. To cancel the selection operation, set the property of the object to `true`. - - For information about how to programmatically initiate a sort operation, see the method. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example demonstrates how to use the event to perform the sorting functionality when the control is bound to a object by setting the property programmatically. - + event is raised when the hyperlink to sort a column is clicked, but before the control handles the sort operation. This enables you to provide an event-handling method that performs a custom routine, such as canceling the sorting operation, whenever this event occurs. + + A object is passed to the event-handling method, which enables you to determine the sort expression for the column and to indicate that the selection operation should be canceled. To cancel the selection operation, set the property of the object to `true`. + + For information about how to programmatically initiate a sort operation, see the method. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example demonstrates how to use the event to perform the sorting functionality when the control is bound to a object by setting the property programmatically. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSorting/CS/gridviewsorting2cs.aspx" id="Snippet2"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSorting/VB/gridviewsorting2vb.aspx" id="Snippet2"::: - - The following example demonstrates how to use the event to cancel a sorting operation. - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSorting/VB/gridviewsorting2vb.aspx" id="Snippet2"::: + + The following example demonstrates how to use the event to cancel a sorting operation. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewSorting/CS/gridviewsortingcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSorting/VB/gridviewsortingvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewSorting/VB/gridviewsortingvb.aspx" id="Snippet1"::: + ]]> @@ -6818,11 +6816,11 @@ Returns the result of a callback event that targets a control. The results of the callback. - control implements the interface and uses the to asynchronously retrieve data and the method to return the retrieved data to the control. - + control implements the interface and uses the to asynchronously retrieve data and the method to return the retrieved data to the control. + ]]> @@ -6859,11 +6857,11 @@ The argument to pass to the event handler. Creates the arguments for the callback handler in the method. - is a helper method that is used by the control to create the arguments for the callback handler in the method. - + is a helper method that is used by the control to create the arguments for the callback handler in the method. + ]]> @@ -6897,11 +6895,11 @@ Gets the data values that are used to uniquely identify each instance of a data-bound control when ASP.NET generates the value. The data values that are used to uniquely identify each instance of a data-bound control when ASP.NET generates the value. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -6938,14 +6936,14 @@ The event argument from which to create a for the event or events that are raised. Raises the appropriate events for the control when it posts back to the server. - method when a postback event occurs to raise the appropriate events for a control. This call occurs in the page life cycle after loading and change notification are complete, but before prerendering occurs. This method has been implemented to create a object for the event or events that are raised. - + method when a postback event occurs to raise the appropriate events for a control. This call occurs in the page life cycle after loading and change notification are complete, but before prerendering occurs. This method has been implemented to create a object for the event or events that are raised. + > [!NOTE] -> This method is used primarily by control developers to extend the control. - +> This method is used primarily by control developers to extend the control. + ]]> @@ -6988,11 +6986,11 @@ Creates the callback script for a button that performs a sorting operation. The callback script for a button that performs a sorting operation. - is a helper method that is used by the control to create the callback script for a button that performs a sorting operation. - + is a helper method that is used by the control to create the callback script for a button that performs a sorting operation. + ]]> @@ -7030,15 +7028,15 @@ Gets or sets the names of the primary key fields for the items displayed in a data-bound control. An array that contains the names of the primary-key fields for the items that are displayed in a control. - instance is cast to an interface. - - This property provides access to the property of the control. It is exposed through the Interface. - - ASP.NET Dynamic Data supports this property. - + instance is cast to an interface. + + This property provides access to the property of the control. It is exposed through the Interface. + + ASP.NET Dynamic Data supports this property. + ]]> @@ -7065,15 +7063,15 @@ Gets or sets the table that is exposed by the data source control to bind to the data-bound control. The table that is exposed by the data source control to bind to the data-bound control. - instance is cast to an interface. - - If the data source contains multiple sources of data, use this property to set the specific data table, collection, or other data for the control to bind to. For example, if the data source is a instance that contains multiple tables, you can specify which table to bind the control to by using this property. - - ASP.NET Dynamic Data supports this property. - + instance is cast to an interface. + + If the data source contains multiple sources of data, use this property to set the specific data table, collection, or other data for the control to bind to. For example, if the data source is a instance that contains multiple tables, you can specify which table to bind the control to by using this property. + + ASP.NET Dynamic Data supports this property. + ]]> @@ -7100,13 +7098,13 @@ Gets or sets the data source object from which the data-bound control retrieves the list of data items. The data source object that the data-bound control uses. - instance is cast to an interface. - - ASP.NET Dynamic Data supports this property. - + instance is cast to an interface. + + ASP.NET Dynamic Data supports this property. + ]]> @@ -7133,13 +7131,13 @@ Gets or sets the ID of the data source from which the data-bound control retrieves the list of data items. The ID of the data source from which the data-bound control retrieves data items. - instance is cast to an interface. - - ASP.NET Dynamic Data supports this property. - + instance is cast to an interface. + + ASP.NET Dynamic Data supports this property. + ]]> @@ -7166,13 +7164,13 @@ Gets or sets the data source object from which the data-bound control retrieves the list of data items. The data source object from which the data-bound control retrieves the list of data items. - instance is cast to an interface. - - ASP.NET Dynamic Data supports this property. - + instance is cast to an interface. + + ASP.NET Dynamic Data supports this property. + ]]> @@ -7209,11 +7207,11 @@ Gets or sets the names of the data fields whose values are appended to the property value to uniquely identify each instance of a data-bound control. The names of the data fields whose values are used to uniquely identify each instance of a data-bound control when ASP.NET generates the value. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -7246,13 +7244,13 @@ Gets a collection of objects that represent the value in a data-bound control. An array that contains the data key of each row in a data-bound control. - instance is cast to an interface. - - ASP.NET Dynamic Data supports this property. - + instance is cast to an interface. + + ASP.NET Dynamic Data supports this property. + ]]> @@ -7290,13 +7288,13 @@ if the row selection is based on data-key values; otherwise, . - instance is cast to an interface. - - ASP.NET Dynamic Data supports this property. - + instance is cast to an interface. + + ASP.NET Dynamic Data supports this property. + ]]> @@ -7329,13 +7327,13 @@ Gets the object that contains the data key value for the selected row in a data-bound control. The data-key value for the selected row. - instance is cast to an interface. - - ASP.NET Dynamic Data supports this property. - + instance is cast to an interface. + + ASP.NET Dynamic Data supports this property. + ]]> @@ -7372,13 +7370,13 @@ Gets or sets the index of the selected row in the data-bound control. The index of the selected row in the data-bound control. - instance is cast to an interface. - - ASP.NET Dynamic Data supports this property. - + instance is cast to an interface. + + ASP.NET Dynamic Data supports this property. + ]]> @@ -7415,13 +7413,13 @@ Gets or sets the control that automatically generates the columns for a data-bound control for use by ASP.NET Dynamic Data. The control that automatically generates the columns for a data-bound control. - instance is cast to an interface. - - ASP.NET Dynamic Data supports this property. - + instance is cast to an interface. + + ASP.NET Dynamic Data supports this property. + ]]> @@ -7459,14 +7457,14 @@ For a description of this member, see . The data-key value for the persisted selected record in a data-bound control. - control is in paging mode. By default, row selection is based on row index. The same row (for example, the third row) is selected on each page. Alternatively, you can enable persistence based on the data key of the selected row. In that case, if you select row 3 on page 1 and you move to page 2, no row is selected on page 2. If you move back to page 1, row 3 is still selected. To enable this functionality, set this property to `true`. - + control is in paging mode. By default, row selection is based on row index. The same row (for example, the third row) is selected on each page. Alternatively, you can enable persistence based on the data key of the selected row. In that case, if you select row 3 on page 1 and you move to page 2, no row is selected on page 2. If you move back to page 1, row 3 is still selected. To enable this functionality, set this property to `true`. + > [!NOTE] -> In versions 2.0, 3.0, and 3.5 of ASP.NET, row selection was based only on row index. By default, row selection in ASP.NET 4 is based on index for backward compatibility. - +> In versions 2.0, 3.0, and 3.5 of ASP.NET, row selection was based only on row index. By default, row selection in ASP.NET 4 is based on index for backward compatibility. + ]]> @@ -7523,11 +7521,11 @@ Gets the value for the control. The value for the control. - property allows the output stream to write the appropriate HTML markup for the control. When the property is set to `true`, this property returns `HtmlTextWriterTag.Div`; otherwise, this property returns `HtmlTextWriterTag.Table`. - + property allows the output stream to write the appropriate HTML markup for the control. When the property is set to `true`, this property returns `HtmlTextWriterTag.Div`; otherwise, this property returns `HtmlTextWriterTag.Table`. + ]]> @@ -7567,24 +7565,24 @@ Gets a object that represents the top pager row in a control. A that represents the top pager row in the control. - property to `true`), an additional row called the pager row is automatically displayed in the control. The pager row contains controls that allow the user to navigate to the other pages and can be displayed at the top, the bottom, or both the top and bottom of the control. Use the property to programmatically access the object that represents the top pager row in a control. - + property to `true`), an additional row called the pager row is automatically displayed in the control. The pager row contains controls that allow the user to navigate to the other pages and can be displayed at the top, the bottom, or both the top and bottom of the control. Use the property to programmatically access the object that represents the top pager row in a control. + > [!NOTE] -> The property is available only after the control creates the top pager row in the event. - - This property is commonly used when you need to programmatically manipulate the top pager row, for example when adding custom content. Any modification to the property must be performed after the control has been rendered; otherwise, the control will overwrite any changes. - - - -## Examples - The following example demonstrates how to use the property to access the top pager row in a control. The property is used to retrieve a control from the pager row. - +> The property is available only after the control creates the top pager row in the event. + + This property is commonly used when you need to programmatically manipulate the top pager row, for example when adding custom content. Any modification to the property must be performed after the control has been rendered; otherwise, the control will overwrite any changes. + + + +## Examples + The following example demonstrates how to use the property to access the top pager row in a control. The property is used to retrieve a control from the pager row. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewTopPagerRow/CS/gridviewtoppagerrowcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewTopPagerRow/VB/gridviewtoppagerrowvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewTopPagerRow/VB/gridviewtoppagerrowvb.aspx" id="Snippet1"::: + ]]> @@ -7614,11 +7612,11 @@ Tracks view-state changes to the control so they can be stored in the control's object. This object is accessible through the property. - @@ -7654,13 +7652,13 @@ Gets or sets the name of the method to call in order to update data. The name of the method. - @@ -7691,24 +7689,24 @@ to perform page validation when this method is called; otherwise, . Updates the record at the specified row index using the field values of the row. - method to programmatically update the record at the specified index in the data source. This method is commonly used when you need to update a record from outside of the control, such as from a different control on the page. - + method to programmatically update the record at the specified index in the data source. This method is commonly used when you need to update a record from outside of the control, such as from a different control on the page. + > [!NOTE] -> This method can be called only for the row that is currently in edit mode, or for a row that contains a two-way data-bound input control. For more information about two-way binding expressions, see [Binding to Databases](https://learn.microsoft.com/previous-versions/aspnet/ms178361(v=vs.100)). - - To specify whether page validation is performed before the update operation, use the `causesValidation` parameter. Calling this method also raises the and events. - - - -## Examples - The following example demonstrates how to use the method to programmatically update a record in a control. - +> This method can be called only for the row that is currently in edit mode, or for a row that contains a two-way data-bound input control. For more information about two-way binding expressions, see [Binding to Databases](https://learn.microsoft.com/previous-versions/aspnet/ms178361(v=vs.100)). + + To specify whether page validation is performed before the update operation, use the `causesValidation` parameter. Calling this method also raises the and events. + + + +## Examples + The following example demonstrates how to use the method to programmatically update a record in a control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewUpdateRow/CS/GridViewUpdateRowcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewUpdateRow/VB/GridViewUpdateRowvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewUpdateRow/VB/GridViewUpdateRowvb.aspx" id="Snippet1"::: + ]]> The control is bound to a data source control, but the associated with the data source is . @@ -7743,21 +7741,21 @@ if the control renders its header in an accessible format; otherwise, . The default is . - property to specify whether the control renders its header row in an accessible format. This property is provided to make the control more accessible to users of assistive technology devices. By default, the value of this property is `true` and the header for the control is rendered using `` table header cell tags. In addition, a `scope="col"` attribute is added to the table header to specify that the header applies to all the cells in the column. The default rendering of the `` element is preserved, rendering text as bold and centered horizontally. Developers can override the style of the `` element using a cascading style sheet. - - If the value of this property is `false`, the header for the control is rendered using `` table cell tags. - - - -## Examples - The following example demonstrates how to use the property to disable the accessible header. - + property to specify whether the control renders its header row in an accessible format. This property is provided to make the control more accessible to users of assistive technology devices. By default, the value of this property is `true` and the header for the control is rendered using `` table header cell tags. In addition, a `scope="col"` attribute is added to the table header to specify that the header applies to all the cells in the column. The default rendering of the `` element is preserved, rendering text as bold and centered horizontally. Developers can override the style of the `` element using a cascading style sheet. + + If the value of this property is `false`, the header for the control is rendered using `` table cell tags. + + + +## Examples + The following example demonstrates how to use the property to disable the accessible header. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/GridViewUseAccessibleHeader/CS/gridviewuseaccessibleheadercs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewUseAccessibleHeader/VB/gridviewuseaccessibleheadervb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/GridViewUseAccessibleHeader/VB/gridviewuseaccessibleheadervb.aspx" id="Snippet1"::: + ]]> @@ -7794,11 +7792,11 @@ Gets or sets the virtual number of items in the data source that the control is bound to when custom paging is used. The virtual number of items in the data source that the control is bound to when custom paging is used. - property is `true`. For more information, see the property. - + property is `true`. For more information, see the property. + ]]>