日期:2014-05-20  浏览次数:20488 次

如何将数据暂存而不马上存入数据库——急急急
想实现用户填完表单,跳转到下一个页面后,还可以返回上一页面修改数据,但此过程不存储任何数据,只是暂存,当用户点击提交后才会存储。
问题很菜,不过困扰N久,感觉用Session或者Cookie都比较复杂,哪位有方便快捷的办法指点一下吧,多谢了!

------解决方案--------------------
……

那就只有ViewState——会更复杂
------解决方案--------------------
放进ViewState中,页面级的缓存
------解决方案--------------------
放进ViewState中
------解决方案--------------------
跳到其它页面,不可能还用ViewState 用 Session 吧,不难呀 Session[ "aaaa "] = xxxx;
xxxx=(DataSet)Session[ "aaaa "]
------解决方案--------------------
session 最佳.
------解决方案--------------------
you may store your data in the dataset temp,,,,
then you can update your database
------解决方案--------------------
应该将整个流程整合到同一个页面中.

将通过容器控件的可见性来决定让用户走到哪一步,

各步骤间需要保持的数据放在页面的ViewState中.

这种事不应该用Session做,因为你很难决定何时将Session里的这些数据Remove掉.
------解决方案--------------------
Wizard控件的功能用panel控件同样可以做到!只不过微软封装了一下而已!相比而言,wizard更智能,写的代码少了!(补充:经过试验,该控件的性能非常优异。)

后台代码:

protected void btn1saveandnext_Click(object sender, EventArgs e)
{
Wizard1.ActiveStepIndex = 1;
}
protected void btn2prev_Click(object sender, EventArgs e)
{
Wizard1.ActiveStepIndex = 0;
}
protected void btn3prev_Click(object sender, EventArgs e)
{
Wizard1.ActiveStepIndex = 1;
}
protected void btn4prev_Click(object sender, EventArgs e)
{
Wizard1.ActiveStepIndex = 2;
}
protected void btn5prev_Click(object sender, EventArgs e)
{
Wizard1.ActiveStepIndex = 3;
}

protected void btn2next_Click(object sender, EventArgs e)
{
Wizard1.ActiveStepIndex = 2;
}
protected void btn3next_Click(object sender, EventArgs e)
{
Wizard1.ActiveStepIndex = 3;
}
protected void btn4next_Click(object sender, EventArgs e)
{
Wizard1.ActiveStepIndex = 4;
}

前台展示层:

<asp:Wizard ID= "Wizard1 " runat= "server " ActiveStepIndex= "0 ">
<WizardSteps>
<asp:WizardStep ID= "WizardStep1 " runat= "server " Title= " ">
<table width= "780 " cellpadding= "0 " cellspacing= "0 " border= "0 ">
<tr>
<td colspan= "4 " align= "left "> 第一步:基本信息 </td>
</tr>
<tr>
<td style= "width:180px "> </td>
<td style= "width:210px "> </td>
<td style= "width:180px "> </td>
<td style= "width:210px "> </td>
</tr>
<tr>
<td colspan= "4 " align= "right ">