ASP.NET(C#)——加一列按钮

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);
            }
posted @ 2016-03-07 21:08  preditctfuture  阅读(277)  评论(0)    收藏  举报