版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dyh12345678/article/details/86130116
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.DataRow) return;
if (e.Row.FindControl("btn_choice") != null)
{
Button btn_choice = (Button)e.Row.FindControl("btn_choice");
btn_choice.Click += new EventHandler(btn_choice_Click);
}
}
private void btn_choice_Click(object sender, EventArgs e)
{
Button button = (Button)sender;
GridViewRow gvr = (GridViewRow)button.Parent.Parent;
string pk = GridView1.DataKeys[gvr.RowIndex].Value.ToString();
}