asp中gridview编辑问题?
在页面拖入button按钮即更新按钮非模板列更新按钮,浏览页面即为编辑状态,只能更新gv第一行,不能更新其他行?代码如下:更新方法publicvoidupdateMag(...
在页面拖入button按钮即更新按钮非模板列更新按钮,浏览页面即为编辑状态,只能更新gv第一行,不能更新其他行? 代码如下:
更新方法
public void updateMag()
{
TextBox txtname = null;
TextBox txtpwd = null;
TextBox txtage = null;
bool message = false;
for (int i = 0; i < this.gvUser.Rows.Count; i++)
{
txtname = this.gvUser.Rows[i].FindControl("txtName") as TextBox;
txtpwd = this.gvUser.Rows[i].FindControl("txtPwd") as TextBox;
txtage = this.gvUser.Rows[i].FindControl("txtAge") as TextBox;
user.Username = txtname.Text.Trim();
user.Password = txtpwd.Text.Trim();
user.Nianling = Convert.ToInt32(txtage.Text.Trim());
user.Uid = int.Parse(this.gvUser.Rows[i].Cells[1].Text.Trim());
message=bll.UpdateUser(user);
if (message == true)
{
Response.Redirect("~/AdminServer.aspx");
this.Bind();
}
else
{
show.Message(this, "修改失败");
}
}
}
//跟新按钮
protected void Button1_Click(object sender, EventArgs e)
{
this.updateMag();
//.........
} 展开
更新方法
public void updateMag()
{
TextBox txtname = null;
TextBox txtpwd = null;
TextBox txtage = null;
bool message = false;
for (int i = 0; i < this.gvUser.Rows.Count; i++)
{
txtname = this.gvUser.Rows[i].FindControl("txtName") as TextBox;
txtpwd = this.gvUser.Rows[i].FindControl("txtPwd") as TextBox;
txtage = this.gvUser.Rows[i].FindControl("txtAge") as TextBox;
user.Username = txtname.Text.Trim();
user.Password = txtpwd.Text.Trim();
user.Nianling = Convert.ToInt32(txtage.Text.Trim());
user.Uid = int.Parse(this.gvUser.Rows[i].Cells[1].Text.Trim());
message=bll.UpdateUser(user);
if (message == true)
{
Response.Redirect("~/AdminServer.aspx");
this.Bind();
}
else
{
show.Message(this, "修改失败");
}
}
}
//跟新按钮
protected void Button1_Click(object sender, EventArgs e)
{
this.updateMag();
//.........
} 展开
1个回答
2011-03-08
展开全部
我的qq778428176,这个我会
追问
2
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询