1.11M Members

changing the text of a combobox after selecting an item from a first combobox

 
0
 

hi,

I have a web form that consists of several Radcombobox. The first combobox gets its list from a database.
After selecting a value from this combobox i would like it to update the text shown on the second Radcombobox. The autopostback is always resetting the value of the second Radcombobox to the first item in its predefined list.

How do I overcome this?

 
0
 

well if you want to change comboboxes items without having to postback , your gonna have to change them with javascript.

if you really do not want to rely on javascript , then you can manage your postbacks with querystring, Session variables , or even cookies but that would be overkill, Session would be fine.

Lets say Combobox1 is States and combo box 2 is Towns or whatever.
When user changes the selectedIndex of combo1 , save the new selectedIndex in a Session variable Session("state") , then on your page load check if postback is true and if it is, check if you have a value for Session("state"), if you do, load the proper items in combo2

alternatively with querystring simply redirect to the same page with "state=UserSelection" at the end of the link ("mypage.aspx?state=something") , and in your page load check for Request("state") and if there is a value load the propper items in combo2.

 
0
 

well if you want to change comboboxes items without having to postback , your gonna have to change them with javascript.

if you really do not want to rely on javascript , then you can manage your postbacks with querystring, Session variables , or even cookies but that would be overkill, Session would be fine.

Lets say Combobox1 is States and combo box 2 is Towns or whatever.
When user changes the selectedIndex of combo1 , save the new selectedIndex in a Session variable Session("state") , then on your page load check if postback is true and if it is, check if you have a value for Session("state"), if you do, load the proper items in combo2

alternatively with querystring simply redirect to the same page with "state=UserSelection" at the end of the link ("mypage.aspx?state=something") , and in your page load check for Request("state") and if there is a value load the propper items in combo2.

hi Phillipe,

Thanks for your post. I managed to solve my issue. I used if (Page.IsPostBack == true) and this sorted out the whole issue and now my form behaves exactly the way I require it to.

Question Answered as of 2 Years Ago by Philippe.Lahaie
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article