We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,275 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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

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?

2
Contributors
2
Replies
3 Days
Discussion Span
1 Year Ago
Last Updated
3
Views
Question
Answered
naheedkassam
Newbie Poster
16 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

Philippe.Lahaie
Posting Whiz
360 posts since Oct 2007
Reputation Points: 103
Solved Threads: 54
Skill Endorsements: 4

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.

naheedkassam
Newbie Poster
16 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by Philippe.Lahaie

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.3108 seconds using 2.67MB