GridView 事件执行两次.
GridView RowDeleting事件 执行两次. 我们在写程序时,可能会碰到有些事件会执行两次,他们都说是MS的BUG,管他了,我们只需要找到解决的办法就行了:下面是一个方法,你只需要调他就行了:
1 private bool Ok2Delete(int passCount)
2
3 {
4
5 Session["delCount"] = Session["delCount"] == null ? 0 : Session["delCount"];
6
7 return !((int)(Session["delCount"] = (((int)Session["delCount"]) + 1) % passCount) == 0);
8
9
10
11 }
12
2
3 {
4
5 Session["delCount"] = Session["delCount"] == null ? 0 : Session["delCount"];
6
7 return !((int)(Session["delCount"] = (((int)Session["delCount"]) + 1) % passCount) == 0);
8
9
10
11 }
12
用法:在事件被fire时加载就行了.
if (!Ok2Delete(2)) return;
浙公网安备 33010602011771号