System.Web.UI.WebControls Namespace BaseDataList Class
Returns the collection of key values for each row in a data listing control.
Script |
[ DataKeyCollection var = ] BaseDataList.DataKeys |
This property can only be used programmatically; it cannot be set when declaring the control.
A DataKeyCollection object that represents the key values for each row in a data listing control.
Use the DataKeys collection to access the key values of each record in a data listing control. This allows you to store the key field with a data listing control without displaying it in the control. This collection is automatically filled with the values from the field specified by the DataKeyField property.
The key field is commonly used in a handler for an event, such as ItemCommand or DeleteCommand, as part of a select or update query string to retrieve and/or revise a specific record in the data source. The key field helps the select or update query string identify the appropriate record to display or modify.
For more information, see Accessing Data with ADO.NET.
The following examples demonstrate using the DataKeys collection to identify the record selected by the user from a data source.
BaseDataList Members DataSource DataMember DataKeyField