2013-01-08 2 views

답변

0

SelectedIndexChanged 이벤트를 사용해보십시오. 이런 식으로 뭔가 :

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e){ 
    TextBox1.Text = GridView1.SelectedRow.Cells[1].Text; 
    TextBox2.Text = GridView1.SelectedRow.Cells[2].Text; 
    . 
    . 
    . 
} 
1

하나 DataKey을하고있는 int하고 버튼의 행입니다 가정은 반드시 선택하지 않은 당신은 당신의 템플릿 필드에 버튼에 다음 함수를 연결 한 :

protected void RowClicked(object sender, EventArgs e) 
{ 
    Button TempButton = sender as Button; 

    if (TempButton != null) 
    { 
     GridViewRow GVR = TempButton.Parent.Parent as GridViewRow; 

     if (GVR != null) 
     { 
      int ID = (int) GridView1.DataKeys[GVR.DataItemIndex].Value; 
     } 
    } 
} 
관련 문제