protected
void
GVProd_RowCommand(
object
sender, GridViewCommandEventArgs e)
{
if (e.CommandName == " down " )
{
因为这里e. CommandArgument已经 在其他用途,所以不能根据它取行号
int prodid = Convert.ToInt32(e.CommandArgument.ToString());
/// /从这里开始
GridViewRow row = null ;
Control cmdControl = e.CommandSource as Control;
row = cmdControl.NamingContainer as GridViewRow;
{
if (e.CommandName == " down " )
{
因为这里e. CommandArgument已经 在其他用途,所以不能根据它取行号
int prodid = Convert.ToInt32(e.CommandArgument.ToString());
/// /从这里开始
GridViewRow row = null ;
Control cmdControl = e.CommandSource as Control;
row = cmdControl.NamingContainer as GridViewRow;
//以上三行,也可用下面的这行替代
//GridViewRow row = ((GridViewRow)(((LinkButton)(e.CommandSource)).Parent.Parent));
string
nownum
=
((TextBox)row.Cells[
3
].FindControl(
"
TxtNum
"
)).Text.ToString();
/// /row就是取出来的行号,然后执行相关的操作
if (nownum.Length == 0 )
{
nownum = " 1 " ;
}
int prodnum = Convert.ToInt32(nownum);
Prod prod = new Prod();
prod.UpProd( " 4 " , System.DateTime.Now, prodnum, prodid);
BindGV();
}
}
/// /row就是取出来的行号,然后执行相关的操作
if (nownum.Length == 0 )
{
nownum = " 1 " ;
}
int prodnum = Convert.ToInt32(nownum);
Prod prod = new Prod();
prod.UpProd( " 4 " , System.DateTime.Now, prodnum, prodid);
BindGV();
}
}