Gridview更新的时候怎么老取不到新值??? 各位大大,Gridview更新的时候怎么老取不到新值??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是否有在Page_Load写if(IsPostBack){//绑定数据} 不然参考:http://blog.csdn.net/insus/archive/2008/03/30/2229898.aspx 把Gridview视图状态EnableViewState设FALSE 就是点击GridView的编辑按钮(COmmandField)后进入GridView的编辑状态,修改字段值后再点击更新保存刚才的修改时,发现根本没作改变,后跟踪发现从GridView取到的新值是空的。。相关代码如下:switch (e.CommandName) { //编辑 case "Edit": GV.EditIndex = index; break; //修改 case "Update": sUserID = GV.Rows[index].Cells[1].Text.ToString();; Hashtable ht = new Hashtable(); ht.Add("sRoleID",((TextBox)GV.Rows[index].Cells[2].Controls[0]).Text.ToString()); lrole.Update(ht); GV.EditIndex = -1; break; //取消 case "Cancel": GV.EditIndex = -1; break; //删除 case "Delete": lrole.sUserID = GV.Rows[index].Cells[1].Text.ToString(); lrole.Delete(); //利用Cart的Remove方法,删除某种图书 break; default: break; } Query();有sPostBack,,, protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { InitData(); Query(); } } 造孽呀,自己代码错了//修改 case "Update": sUserID = GV.Rows[index].Cells[1].Text.ToString();; Hashtable ht = new Hashtable(); ht.Add("sRoleID",((TextBox)GV.Rows[index].Cells[2].Controls[0]).Text.ToString()); lrole.Update(ht); GV.EditIndex = -1; break; 改成//修改 case "Update": sUserID = ((TextBox)GV.Rows[index].Cells[1].Controls[0]).Text.ToString(); Hashtable ht = new Hashtable(); ht.Add("sUserID", sUserID); ht.Add("sRoleID",((TextBox)GV.Rows[index].Cells[2].Controls[0]).Text.ToString()); lrole.Update(ht); GV.EditIndex = -1; break; treeview value用js的获取? 高分在线求关于条形码扫描枪和称重器的解决方法 他们有什么区别?thx~ 把gridview 嵌到table javascript如何能实现这样的功能呢??请进````` 自定义控件的指令问题 求分页的存储过程 正在学asp.net 请大家推荐几个小点的web项目的例子(有源代码可以学习的),要小点的 安装部署程序中如何向master中添加killspid这个存储过程用来中止当前所有访问数据库联接 高手帮忙看看,有关水晶报表 请问如何选中放在AJAX控件 TabContainer中的控件? GridView 编辑状态问题?
if(IsPostBack)
{
//绑定数据
}
http://blog.csdn.net/insus/archive/2008/03/30/2229898.aspx
{
//编辑
case "Edit":
GV.EditIndex = index;
break; //修改
case "Update":
sUserID = GV.Rows[index].Cells[1].Text.ToString();;
Hashtable ht = new Hashtable();
ht.Add("sRoleID",((TextBox)GV.Rows[index].Cells[2].Controls[0]).Text.ToString());
lrole.Update(ht);
GV.EditIndex = -1;
break; //取消
case "Cancel":
GV.EditIndex = -1;
break; //删除
case "Delete":
lrole.sUserID = GV.Rows[index].Cells[1].Text.ToString();
lrole.Delete(); //利用Cart的Remove方法,删除某种图书
break;
default:
break;
}
Query();有sPostBack,,, protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
InitData();
Query();
}
}
case "Update":
sUserID = GV.Rows[index].Cells[1].Text.ToString();;
Hashtable ht = new Hashtable();
ht.Add("sRoleID",((TextBox)GV.Rows[index].Cells[2].Controls[0]).Text.ToString());
lrole.Update(ht);
GV.EditIndex = -1;
break; 改成
//修改
case "Update":
sUserID = ((TextBox)GV.Rows[index].Cells[1].Controls[0]).Text.ToString();
Hashtable ht = new Hashtable();
ht.Add("sUserID", sUserID);
ht.Add("sRoleID",((TextBox)GV.Rows[index].Cells[2].Controls[0]).Text.ToString());
lrole.Update(ht);
GV.EditIndex = -1;
break;