gridview如何在更新前,经过程序判断,而决定是否取消更新

edwardliu 2009-08-13 11:38:51
判断更新时输入的数据类型,决定是否继续更新还是提醒输入错误。
在GridView1_RowUpdating事件中判断是否能够更新
如果可以更新,当然就不用做什么,让他更新就可以了
但是如果判断不能更新,要用什么语句停止更新呢?
谢谢各位。
...全文
99 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
bychgh 2009-08-13
  • 打赏
  • 举报
回复


public bool UpdateInfo(AAModel AAModel)
{
....
if (....)
{
this.errMessage = "不能更新信息!";
return false;
}
return true;

}


????
阿非 2009-08-13
  • 打赏
  • 举报
回复


protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
if (条件)
{
e.Cancel = true;
ClientScript.RegisterStartupScript(GetType(), "cancel", "<script language=javascript>alert('输入格式不对!'); </script>");
return ;
}
else
{ }
}


edwardliu 2009-08-13
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 jerry_zuo 的回复:]
C# codeprotectedvoid GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{if (条件)
{
Response.Write(" <script language=javascript>alert('输入格式不对!'); </script>");//这个你页面CSS会乱return;//直接 返回 }else
{

}

}
?????
[/Quote]
确实页面乱了,不知道是为什么呢
我加了return,是返回了,但是仍然进行了更新啊,如何让他不要更新?
jerry_zuo 2009-08-13
  • 打赏
  • 举报
回复

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
if (条件)
{
Response.Write(" <script language=javascript>alert('输入格式不对!'); </script>");//这个你页面CSS会乱
return;//直接 返回
}
else
{

}

}

?????
阿非 2009-08-13
  • 打赏
  • 举报
回复
return;
edwardliu 2009-08-13
  • 打赏
  • 举报
回复
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
if (条件)
{
Response.Write("<script language=javascript>alert('输入格式不对!');</script>");
//此处写如何停止更新,请教是什么样的语句。
}
else
{

}

}

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧