单按钮插入/更新 [英] Insert/Update on single button
问题描述
我 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??
推荐答案
守在viestate的行动,并检查什么价值它是。
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屋!