asp.net.ph

DetailsView.DataKeyNames Property

System.Web.UI.WebControls Namespace   DetailsView Class


.NET Framework version 2.0

Sets or retrieves the names of the primary key fields in the data source bound to the DetailsView control.

Syntax


Inline <asp:detailsview datakeynames = strField1, strField2 ... >
Script DetailsView.DataKeyNames [ = strField1, strField2 ... ]

Property Value


strField1, strField2 An array specifying the names of the primary key fields in the data source bound to the DetailsView control.

The property is read/write with no default value.

NOTE: The specified field or fields must contain unique values ( no duplicate entries ).

Remarks

Use the DataKeyNames property to specify a comma-separated list of field names that represent the primary key of the data source.

When the DataKeyNames property is set, the DetailsView control automatically creates a DataKey object that contains the key/value pairs of the field or fields listed in the DataKeyNames property for the current record. This DataKey object is then stored in the DetailsView control's DataKey property.

NOTE: You must set the DataKeyNames property for the built-in updating, deleting, and inserting features of the DetailsView control to work.

Example

The following example demonstrates how to use the DataKeyNames property to specify the key field for the data source bound to the DetailsView control.

<asp:detailsview id = "msgView" runat = "server"
   datasourceid = "messages"
   datakeynames = "MessageID"
   width=80% cellpadding=5
   allowpaging
   ...
   >
See Also

DetailsView Members   DataKey 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