2011-05-23 94 views

回答

2

你可以得到它在RowCommand事件在GridView的。

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 
{ 
    if (e.CommandName == "Edit") 
    { 
     e.CommandArgument // Return Primary key 
     GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer); 
     row.Cells[0]./// 
     row.Cells[1]./// 
     ................ 
    } 
} 
0

保护无效grdList_RowEditing(对象发件人,GridViewEditEventArgs E)

{

int test_reg_Id = Convert.ToInt32(grdList.DataKeys[e.NewEditIndex].Values[0]); 
    string query = "select * from test_reg where Id=" + test_reg_Id + ""; 
    query += Session["test_reg_Id"].ToString(); 
    dtable = con.sqlSelect(query); 
    txt_id.Text = dtable.Rows[0][0].ToString(); 
    txtuname.Text = dtable.Rows[0][1].ToString(); 
    txtpass.Text = dtable.Rows[0][2].ToString(); 
    ddlcountry.SelectedItem.Text = dtable.Rows[0][3].ToString(); 

}

相关问题