单按钮插入/更新 [英] Insert/Update on single button

查看:82
本文介绍了单按钮插入/更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

modalpopup 在文本框它

用户获取到模式弹出之前,他要么点击添加或编辑。

如果他点击ADD,所有的文本框是空的,他会添加一个新的地址。

如果他点击编辑,已经包含了他的地址文本框和他得到修改自己的地址。

现在我有一个单一的SAVE按钮上,我必须决定在文本框的数据是否需要将 INSERTED(添加)更新时(编者)
如何做到这一点?
我的意思是我该如何找出如果用户点击添加或编辑??

I have modalpopup with textboxes in it.
Before the user gets to the modal popup, he either clicks ADD or EDIT.
If he clicks ADD, all the textboxes are empty and he gets to add a new address.
If he clicks EDIT, the textboxes already contain his address and he gets to edit his address.

Now I have a single SAVE button on which I have to decide whether the data in the textboxes needs to be INSERTED (ADDED) or UPDATED (EDITED).
How do I achieve this?
I mean how do I find out if the user has clicked on ADD or EDIT??

推荐答案

守在vie​​state的行动,并检查什么价值它是。

keep the action in the viestate and check what value it is.

如果用户点击修改,然后在editclick

If user click edit then on editclick

ViewStat["Action"]="Edit";

在保存按钮检查的视图状态值

On save button check for the view state value

if(ViewStat["Action"]!=null)
{
   if(ViewStat["Action"].ToString()=="Edit")
   {
     //update statement
   }
   else
   {
       //insert statement
   }
}

此外,您还可以将其设置为空或空的取消点击

Also you can also set it to empty or null on cancel click

ViewState["Action"]=null;

这篇关于单按钮插入/更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆