Hi,
I'd like to store the contents of a listbox in a session variable. No error is produced from the assignment statement, but I cannot retrieve the items from the session variable afterwards. Thanks.
//The following code is in page load...
if(Session["lstGrpMembers"] == null)
{
//set the session variable equal to the webform's listbox
//this does not produce an error
Session["lstGrpMembers"] = this.lstGrpMembers;
}
else
{
//this code throws an error because the session variable does not have an 'Items' property.
foreach (ListItem itmGrpMember in Session ["lstGrpMembers"].Items)
{
lstGrpMembers.Items.Add(itmGrpMember);
}
}
I'd like to store the contents of a listbox in a session variable. No error is produced from the assignment statement, but I cannot retrieve the items from the session variable afterwards. Thanks.
//The following code is in page load...
if(Session["lstGrpMembers"] == null)
{
//set the session variable equal to the webform's listbox
//this does not produce an error
Session["lstGrpMembers"] = this.lstGrpMembers;
}
else
{
//this code throws an error because the session variable does not have an 'Items' property.
foreach (ListItem itmGrpMember in Session ["lstGrpMembers"].Items)
{
lstGrpMembers.Items.Add(itmGrpMember);
}
}