Trying to understand transfering listbox values/items with sessions.

前提是你 提交于 2019-12-02 08:41:58

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"]);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!