October 2010
Intermediate to advanced
1920 pages
73h 55m
English
You associate a value with each row in a GridView by providing a value for the GridView control’s DataKeyNames property. You can assign the name of a single database column to this property, or you can assign a comma-separated list of column names to this property.
For example, the Employees database table uses two columns—the employee first and last name—as a primary key. The page in Listing 11.4 displays employee details when you select a particular employee (see Figure 11.3).
Figure 11.3. Displaying employee details.

Listing 11.4. SelectDataKeys.aspx
In Listing 11.4, the SelectedDataKey() method retrieves the primary ...