Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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# 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
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900