System.Web.UI.WebControls Namespace BaseDataList Class
Sets or retrieves the key field in the data source specified by the DataSource property.
Inline |
<asp:basedatalist datakeyfield = strFieldName ... > |
Script |
BaseDataList.DataKeyField [ = strFieldName ] |
strFieldName |
String specifying the name of the key field in the specified DataSource. |
The property is read/write with no default value.
Use the DataKeyField property to specify the field in the DataSource that will be used as the key column that serves as the record identifier. The specified field, which must contain unique values ( no duplicate entries ), is used to populate the DataKeys collection. This allows you to store the key field with a data listing control without displaying it in the control.
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.
The following examples demonstrate using the DataKeyField property to identify the record selected by the user from a data source.
BaseDataList Members DataSource DataMember DataKeys