Posted 29 Sep
Link to this post
I have the following scenario:
- a main aspx page
- a user control inside that aspx.page, lets call this parent_user_control
- two RadComboBox, with only numbers on them.
- The first one, RadComboBox1, for example when the user chooses 2, it will dynamically generate 2 user controls, lets call them child_user_control_1
- The second one, RadComboBox2, for example when the user chooses 1, it will dynamically generate 1 user control, lets call it child_user_control_2.
- child_user_control_2, has another RadComboBox, called RadComboBox_2_1, again with numbers only, that dynamically generates another user control, called grandchild_user_control.
- grandchild_user_control has a RadComboBox called RadComboBox_grandchild, with an EmptyMessage="Please select", and only numbers, but the numbers must match RadComboBox1, as in, when 2 was chosen, only options 1 through 2 should appear in this RadComboBox_grandchild. If the value from RadComboBox1 changes to 5, then the range of values in RadComboBox_grandchild should change to 1 through 5. Same if it decreases from 2 to 1, only the value 1 should be available.
- I properly handled the recreation of dynamic user controls, so all values persist, and the values in RadComboBox_grandchild get properly updated.
Here is the problem:
When I change the value to a smaller number, say from 3 to 1, and I have, for example, the value 2 already chosen in RadComboBox_grandchild, the list gets updated, and in the code_behind the values change correctly (as in selectedIndex is -1, selectedItem is null, etc.) BUT, I do not see "Please select", I still see the value "2", even though it is no longer in the list.
How can I avoid this? How can I make it show the EmptyMessage "Please select" again? I tried the ClearSelection method, but it didn't do anything, because it already is without a selection. It seems to me that the mechanism used to persist the values from the previous postback, is forcefully persisting a value that no longer exists.