if (e.CommandName == "select")
{
//获取点击按钮的行号
GridViewRow drv = ((GridViewRow)(((Button)(e.CommandSource)).Parent.Parent)); //此得出的值是表示那行被选中的索引值
//按照Gridview取数
GoodID = GridView1.Rows[drv.RowIndex].Cells[0].Text;
Name = GridView1.Rows[drv.RowIndex].Cells[1].Text;
price =Convert.ToDouble(GridView1.Rows[drv.RowIndex].Cells[2].Text);
Quantity =Convert.ToInt32( GridView1.Rows[drv.RowIndex].Cells[3].Text);
Response.Redirect("~/Emp/MakeOrder.aspx?GoodID="+GoodID+"&Name="+Name+"&price="+price+"&Quantity="+Quantity);
}
ASP.NET(C#)——加一列按钮
原文:http://www.cnblogs.com/bluewhy/p/5251913.html