This is a migrated thread and some comments may be shown as answers.

Load of Demand - Unable to Set SelectedValue

4 Answers 198 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeff Reinhardt
Top achievements
Rank 1
Jeff Reinhardt asked on 21 Oct 2010, 02:32 PM
I have two load on demand radcomboboxes that are working great, however, in the page load I try to set the seleceted value to session values:
if (Session["FacilityID"] != null)
            {
                FacilityID = Utils.ToInteger(Session["FacilityID"].ToString());
                if (Utils.ToInteger(radcmbFacility.SelectedValue.ToString()) != FacilityID)
                {
                    radcmbFacility.SelectedValue = FacilityID.ToString();
                }
            }
if I pause execution of the code, the line setting the value does run, and after it runs I can hover over the SelectedValue and it shows the correct value, however,  on the page the combobox still shows the empty message instead of the text for the selected value.





4 Answers, 1 is accepted

Sort by
0
Richard M
Top achievements
Rank 1
answered on 21 Oct 2010, 04:03 PM
I have seen this same behavior.   I believe this is done on purpose.  If everytime the dropdown opened, or the items were requested, it would select your value.   So you'd never be able to change it.  It would keep defaulting back.   I think it has to work this way to work at all.
0
Jeff Reinhardt
Top achievements
Rank 1
answered on 21 Oct 2010, 04:10 PM
I understand and see what you are saying Richard, but there should be a way to set an initial value and then ignore it one future posts just like using IsPostback on a regular form page.  Here I could do the same thing so why not allow it to be set, then it is the coders responsibility to make sure they are not overriding a user, cause if I set a textbox and do not check postback, it will continue to replace a user's input too.
0
Richard M
Top achievements
Rank 1
answered on 21 Oct 2010, 04:12 PM
I have struggled with this on my project for a couple months now.   I think what you say there might have to do with the ajax command they use to load on demand, it happens before viewstate.   And since it's load on demand, it's always a postback.

I'm with you, it'd be nice if there was a solution to this, I know I could use it to meet some customer demands, but I have had to work around it as a limitation of the control.

Does this help?  It wasn't a solution for me.

http://www.telerik.com/support/kb/aspnet-ajax/combobox/setting-an-initial-value-in-radcombobox-while-using-load-on-demand.aspx
0
Cori
Top achievements
Rank 2
answered on 21 Oct 2010, 07:21 PM
Hello Jeff,

You should also set the Text property to the SelectedValue. The reason being, is because the RadComboBox has no items in it, setting a selected value will not set the text.

I hope that helps.
Tags
ComboBox
Asked by
Jeff Reinhardt
Top achievements
Rank 1
Answers by
Richard M
Top achievements
Rank 1
Jeff Reinhardt
Top achievements
Rank 1
Cori
Top achievements
Rank 2
Share this question
or