Trying to understand transfering listbox values/items with sessions.

前端 未结 1 1131
太阳男子
太阳男子 2021-01-27 16:14

On my first page I have two listboxes for Movies and Snacks

They are called lbDisplay for Movies and lbSelected f

相关标签:
1条回答
  • 2021-01-27 16:55

    On the 2nd page say you have another list box (say ListBox1) to which you want to assign the passed values then use the any one of the foll. 3 methods:

       ListBox  ListBox1 = null;
    
            ListBox1 = Session["lbSelectedMovies"] as ListBox;
    

    OR

    ListBox ListBox1 = new ListBox();       
        foreach (ListItem Item in ((ListBox)(Session["lbSelectedMovies"])).Items)
        {          
            ListBox1.Items.Add(new ListItem(Item.Text, Item.Value));
        }
    

    OR

    ListBox1.Items.AddRange((ListItem[])Session["lbSelectedMovies"]);
    
    0 讨论(0)
提交回复
热议问题