asp.net.ph

BaseDataList.DataKeys Property

System.Web.UI.WebControls Namespace   BaseDataList Class


Returns the collection of key values for each row in a data listing control.

Syntax


Script [ DataKeyCollection var = ] BaseDataList.DataKeys

This property can only be used programmatically; it cannot be set when declaring the control.

Property Value

A DataKeyCollection object that represents the key values for each row in a data listing control.

Remarks

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.

Example

The following examples demonstrate using the DataKeys collection 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   DataKeyField 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