| |||||||||
GridView.DataKeys PropertySystem.Web.UI.WebControls Namespace GridView Class .NET Framework version 2.0 Returns a collection of DataKey objects that represent the data key value of each row in a GridView control. Syntax
This property can only be used programmatically; it cannot be set when declaring the control. Property ValueA DataKeyArray object that represents the data key for each row in a GridView control. RemarksUse the DataKeys collection to access the key values of each record in a GridView control.
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 using the properties described above to retrieve the selected item in the DataKeys collection.
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