Listbox populate with session value

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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;
 
Selection will be maintained only within the same page postback (of course,
view state should have been enabled) not across page navigations.
 
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.
 
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
 
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"
 
Back
Top