|
|
 |
 |
 |
 |
Listbox populate with session value
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.
On Jun 5, 7:27 pm, Smita <S @discussions.microsoft.com> wrote: > 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;
-----------------------------------------------Reply-----------------------------------------------
Selection will be maintained only within the same page postback (of course, view state should have been enabled) not across page navigations.
"Smita" wrote: > 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.
On Jun 6, 11:11 am, Siva M <shiva @online.excite.com> wrote: > 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. -----------------------------------------------Reply-----------------------------------------------
The Selected value is only available from ViewState on the same page. You are navigating to different pages and then coming back. You need to store the selected value index in session also, and restore it say, in your Page_Load handler. Peter Site: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com Short urls & more: http://ittyurl.net
"Smita" wrote: > 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.
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" wrote: > 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.
On Jun 6, 4:21 pm, dbgrick <dbgr @discussions.microsoft.com> wrote: > 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"
|
 |
 |
 |
 |
|