如何将数据暂存而不马上存入数据库——急急急
想实现用户填完表单,跳转到下一个页面后,还可以返回上一页面修改数据,但此过程不存储任何数据,只是暂存,当用户点击提交后才会存储。
问题很菜,不过困扰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 ">
<asp:Button ID= "btn1saveandnext " runat= "server " Text= "保存&下一步 " OnClick= "btn1saveandnext_Click " />
</td>
</tr>
</table>
</asp:WizardStep>
<asp:WizardStep ID= "WizardStep2 " 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 ">
<asp:Button ID= "btn2prev " runat= "server " Text= "上一步 " OnClick= "btn2prev_Click "/>
<asp:Button ID= "btn2saveandnew " runat= "server " Text= "保存&新增 " />
<asp:Button ID= "btn2next " runat= "server " Text= "下一步 " OnClick= "btn2next_Click " />
</td>
</tr>
</table>
</asp:WizardStep>
<asp:WizardStep ID= "WizardStep3 " 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 ">
<asp:Button ID= "btn3prev " runat= "server " Text= "上一步 " OnClick= "btn3prev_Click "/>
<asp:Button ID= "btn3saveandnew " runat= "server " Text= "保存&新增 " />
<asp:Button ID= "btn3next " runat= "server " Text= "下一步 " OnClick= "btn3next_Click "/>
</td>
</tr>
</table>
</asp:WizardStep>
<asp:WizardStep ID= "WizardStep4 " 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 ">
<asp:Button ID= "btn4prev " runat= "server " Text= "上一步 " OnClick= "btn4prev_Click "/>
<asp:Button ID= "btn4saveandnew " runat= "server " Text= "保存&新增 " />
<asp:Button ID= "btn4next " runat= "server " Text= "下一步 " OnClick= "btn4next_Click "/>
</td>
</tr>
</table>
</asp:WizardStep>
<asp:WizardStep ID= "WizardStep5 " 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 ">
<asp:Button ID= "btn5prev " runat= "server " Text= "上一步 " OnClick= "btn5prev_Click "/>
<asp:Button ID= "btn5finish " runat= "server " Text= "完成 " />
</td>
</tr>
</table>
</asp:WizardStep>
</WizardSteps>
<StartNavigationTemplate>
</StartNavigationTemplate>
<StepNavigationTemplate>
</StepNavigationTemplate>
<FinishNavigationTemplate>
</FinishNavigationTemplate>
<SideBarTemplate>
</SideBarTemplate>
</asp:Wizard>
[解决办法]
保存到文件吧
------解决方案--------------------
可以分别放到一个面版容器里,点击下一页的时候将容器的可视设为flase
[解决办法]
做个结构,放入Session中
[解决办法]
把你的数据放到一个对象里,把对象存到session里
[解决办法]
我觉得这个用cookie得方式比较好,前一个页面存储条件到cookie中,点击返回得时候去读取
[解决办法]
Session比较方便,用一个DataTable保存数据,把这个DataTable直接放到Session中!
[解决办法]
事务!~
[解决办法]
用session怕丟,就啓用state server啊