| |||||||||||||
GridView.DataKeyNames PropertySystem.Web.UI.WebControls Namespace GridView Class .NET Framework version 2.0 Sets or retrieves the names of the primary key fields in the data source bound to the GridView control. Syntax
Property Value
The property is read/write with no default value.
RemarksUse the DataKeyNames property to specify the field or fields in the data source bound to the GridView control that will be used as the key column or columns that serve to uniqely identify each record.
When the DataKeyNames property is set, the GridView control automatically populates its DataKeys collection with the values from the specified field or fields, which provides a convenient way to store and retrieve the primary keys of each row, without having to display it in the control. The GridView provides several properties for retrieving the selected item in the DataKeys collection.
The key field is commonly used in a handler for an event, such as the SelectedIndexChanged event, where the value of the key field is used to build the SQL Select or Update query to retrieve and/or revise a specific record in the data source. The key field simplifies identifying the appropriate record to display or modify. ExampleThe following examples demonstrate how to set the DataKeyNames property to enable identifying the record selected by the user from a GridView control.
See Also |
| ||||||||||||
Check out related books at Amazon
© 2000-2008 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 aspxtreme