gridview 按钮 获得该行

 protected void Button2_Click(object sender, EventArgs e)
        {
            GridViewRow row = ((Button)sender).Parent.Parent as GridViewRow;

         string id = GridView1.DataKeys[row.RowIndex].Value.ToString(); //获得该行主键
        }

原文地址:https://www.cnblogs.com/puzi0315/p/2604065.html