Listbox populate with session value

G

Guest

Iam fairly new to .net programming. I have a listbox with multi-select
option. If page not postback, i do the data binding. On selection of values,
i save it in a session varible as this is used my couple of other pages. When
i traverse from the main page(where list box is created) to the sub pages and
come back , the value is lost and i do not have selected in the list box. Can
anyone please tell me what iam missing. I still have the values in the
session variable.
thanks in advance.
 
A

Alexey Smirnov

Iam fairly new to .net programming. I have a listbox with multi-select
option. If page not postback, i do the data binding. On selection of values,
i save it in a session varible as this is used my couple of other pages. When
i traverse from the main page(where list box is created) to the sub pages and
come back , the value is lost and i do not have selected in the list box. Can
anyone please tell me what iam missing. I still have the values in the
session variable.
thanks in advance.

You should select the value of the list again.

ListBox.Items.FindByValue(Session["MyListValue"].ToString()).Selected
= true;
 
G

Guest

Selection will be maintained only within the same page postback (of course,
view state should have been enabled) not across page navigations.
 
A

Alexey Smirnov

Selection will be maintained only within the same page postback (of course,
view state should have been enabled) not across page navigations.

He used a Session object, not a ViewState.
 
G

Guest

Smita,
Try enabling view state for the listbox control. This will maintain your
values, even with postback. As long as you do not reload the page.

Rick D.
Contractor
 
A

Alexey Smirnov

Smita,
Try enabling view state for the listbox control. This will maintain your
values, even with postback. As long as you do not reload the page.

Rick D.
Contractor

Rick.... the view state doesn't help - "When i traverse from the main
page(where list box is created) to the sub pages and
come back , the value is lost"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top