如何将列表框项目存储到会话中 [英] How to store list box items into session

查看:60
本文介绍了如何将列表框项目存储到会话中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai friends,



我在列表框中有一个疑问。



我创建了一个列表框。它正在填充sql表中的值。它还允许多选择为true。您可以告诉我如何将列表框项值存储在会话中。



我尝试过以下代码:

ASP.NET代码:



Hai friends,

I have one doubt in list box.

I have created a list box.It is populating the values from a sql table.It also allows multi selection to true.Can u please tell me how can i store the listbox item values in a session.

I have tried the below code:
ASP.NET Code:

<tr>
                <td align="right">
                 
                  
                  <asp:Label ID="lblPrimaryImpactedArea" runat="server" Text="Primary Impact Area"></asp:Label>
                </td>
                <td>
                   <asp:ListBox ID="lstPrimaryImpactedArea" runat="server" SelectionMode="Multiple">
                      
                    </asp:ListBox>
                </td>
               
            </tr>





C#代码:





C# code:

Session["PrimaryImpactedArea"] = lblPrimaryImpactedArea.SelectedItem.Text;





假如我想将上面的列表框项目用到下一页我尝试了以下代码:



查看下一页的列表框项目:



Suppose if i want to use the above listbox items into next page I tried the below code:

To View the listbox items in next page:

string PrimaryImpactedArea = System.Web.HttpContext.Current.Session["PrimaryImpactedArea"].ToString();
             lstPrimaryImpactedArea.SelectedItem.Text = Session["PrimaryImpactedArea"].ToString();
             lstPrimaryImpactedArea.Enabled = false;





但它不起作用。请帮助我。



先谢谢



But it is not working.Please help me.

Thanks in Advance

推荐答案

请参考这里,

http://stackoverflow.com/questions/9410507/add-listbox-to-session [ ^ ]


这篇关于如何将列表框项目存储到会话中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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