protected void Gridbookbig_RowCommand(object sender, GridViewCommandEventArgs e)
{
int i_rowindex;
int bbid;
if (e.CommandName == "delbookbig")
{ i_rowindex = Convert.ToInt32(e.CommandArgument.ToString());//获取当前行索引
bbid = Convert.ToInt32(Gridbookbig.Rows[i_rowindex].Cells[0].Text);//获取当前行的id值
string sql;
sql = "delete from BookbigT where bbid=" + bbid + "";
string StrConn = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
ExecPro.ExecPro.ExecuteDataset(StrConn, CommandType.Text, sql);
Gridbookbig.DataSource = ExecPro.ExecPro.ExecuteDataset(StrConn, CommandType.StoredProcedure, "bookbigpro");
Gridbookbig.DataBind();
Response.Write("<script language=javascript>alert('删除成功!');history.back(-1);</script>");
}
我做的是一个删除命令,bbid 在数据库里是int类型且是自动编号,对应的id绑定在gridview的第一行,我对赋值上面还不太清楚,bbid = Convert.ToInt32(Gridbookbig.Rows[i_rowindex].Cells[0].Text)这样进行转换运行起来提示我错误要我调试,我把该行注销掉则会提示具体错误。对bbid类型那一行的该怎么样进行转换,求教高手,在线等答复
{
int i_rowindex;
int bbid;
if (e.CommandName == "delbookbig")
{ i_rowindex = Convert.ToInt32(e.CommandArgument.ToString());//获取当前行索引
bbid = Convert.ToInt32(Gridbookbig.Rows[i_rowindex].Cells[0].Text);//获取当前行的id值
string sql;
sql = "delete from BookbigT where bbid=" + bbid + "";
string StrConn = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
ExecPro.ExecPro.ExecuteDataset(StrConn, CommandType.Text, sql);
Gridbookbig.DataSource = ExecPro.ExecPro.ExecuteDataset(StrConn, CommandType.StoredProcedure, "bookbigpro");
Gridbookbig.DataBind();
Response.Write("<script language=javascript>alert('删除成功!');history.back(-1);</script>");
}
我做的是一个删除命令,bbid 在数据库里是int类型且是自动编号,对应的id绑定在gridview的第一行,我对赋值上面还不太清楚,bbid = Convert.ToInt32(Gridbookbig.Rows[i_rowindex].Cells[0].Text)这样进行转换运行起来提示我错误要我调试,我把该行注销掉则会提示具体错误。对bbid类型那一行的该怎么样进行转换,求教高手,在线等答复
string id = row.Cells[0].Text;
不行用DataKeys