MSDN Library
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

GridView.IPersistedSelector.DataKey Property

For a description of this member, see IPersistedSelector.DataKey.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

DataKey IPersistedSelector.DataKey { get; set; }

Property Value

Type: System.Web.UI.WebControls.DataKey
The data-key value for the persisted selected record in a data-bound control.



You can specify how selected rows are persisted when the GridView 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.


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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1, 3.0 SP2, 2.0 SP2
© 2015 Microsoft