asp.net问题。。gridview中要实现编辑更新。我的数据操作是在数据访问层操作。为什么点更新后,更新的是0

2025-03-22 21:22:20
推荐回答(2个)
回答1:

没看过你写的代码,你看看更新的sql语句是不是有问题,仔细调试一下

回答2:

这是我写的一个例子,你看下对你有没有帮助。。。
//更新
protected void gv_user_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow gvr = gv_user.Rows[e.RowIndex];

//获取用户名
string uname = ((TextBox)gvr.Cells[0].FindControl("txt_uname")).Text;

//获取用户密码
string upwd = ((TextBox)gvr.Cells[1].FindControl("txt_upwd")).Text;

int id = Convert.ToInt32(gv_user.DataKeys[e.RowIndex].Value.ToString());

if (bll.UpdateUserByUid(uname,upwd,id))
{
gv_user.EditIndex = -1;
Bind();
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "msg", "");
}
}