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:";
    }
posted @ 2009-09-22 08:19  i'm zjz  阅读(946)  评论(0编辑  收藏  举报