asp.net.ph

BaseDataList.DataKeyField Property

System.Web.UI.WebControls Namespace   BaseDataList Class


Sets or retrieves the key field in the data source specified by the DataSource property.

Syntax


Inline <asp:basedatalist datakeyfield = strFieldName ... >
Script BaseDataList.DataKeyField [ = strFieldName ]

Property Value


strFieldName String specifying the name of the key field in the specified DataSource.

The property is read/write with no default value.

Remarks

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.

Example

The following examples demonstrate using the DataKeyField property to identify the record selected by the user from a data source.

DataList SelectedIndex Property
Run Sample | View Source
DataGrid SelectedIndex Property
Run Sample | View Source
See Also

BaseDataList Members   DataSource   DataMember   DataKeys Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph