asp.net.ph

FormView.DataKeyNames Property

System.Web.UI.WebControls Namespace   FormView Class


.NET Framework version 2.0

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

Syntax


Inline <asp:formview datakeynames = strField1, strField2 ... >
Script FormView.DataKeyNames [ = strField1, strField2 ... ]

Property Value


strField1, strField2 An array specifying the names of the primary key fields in the data source bound to the FormView 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 FormView 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 FormView control's DataKey property.

NOTE: You must set the DataKeyNames property for the built-in updating, deleting, and inserting features of the FormView 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 FormView control.

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

FormView 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