GridView SelectIndexChanged 事件
protected void gridEmployees_SelectedIndexChanged(object sender, EventArgs e)
{
int index = gridEmployees.SelectedIndex;
// You can retrieve the key field from the SelectedDataKey property.
int ID = (int)gridEmployees.SelectedDataKey.Values["EmployeeID"];
// You can retrieve other data directly from the Cells collection,
// as long as you know the column offset.
string firstName = gridEmployees.SelectedRow.Cells[2].Text;
string lastName = gridEmployees.SelectedRow.Cells[3].Text;
lblRegionCaption.Text = "Regions that " + firstName + " " + lastName +
" (employee " + ID.ToString() + ") is responsible for:";
}
{
int index = gridEmployees.SelectedIndex;
// You can retrieve the key field from the SelectedDataKey property.
int ID = (int)gridEmployees.SelectedDataKey.Values["EmployeeID"];
// You can retrieve other data directly from the Cells collection,
// as long as you know the column offset.
string firstName = gridEmployees.SelectedRow.Cells[2].Text;
string lastName = gridEmployees.SelectedRow.Cells[3].Text;
lblRegionCaption.Text = "Regions that " + firstName + " " + lastName +
" (employee " + ID.ToString() + ") is responsible for:";
}