ComboBox SelectedValue Not Working

23 posts, 0 answers
  1. Praveen
    Praveen avatar
    13 posts
    Member since:
    Mar 2009

    Posted 18 Sep 2009 Link to this post

    The SelectedValue is working in the WebPage but if you create a usercontrol and put the RadComboBox and try to set the

    SelectedValue it is not working. Any idea why it is behaving like this?

  2. Adam
    Adam avatar
    1 posts
    Member since:
    Apr 2009

    Posted 21 Sep 2009 Link to this post

    Hi,

    We are experienceing this as well.

    The Selected value is being set but is not displaying in the rendered combobox.

    This is quite a serious issue for us so could you advise of the fix or work around ASAP.

    Thanks.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 23 Sep 2009 Link to this post

    Hi,

    What is the exact RadComboBox setup you are using?
    We tested the behavior locally, but couldn't reproduce the issue. Please find attached our test files.
    Could you modify them so we can see the problem you experience?

    Kind regards,
    Helen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Absolute Data Group
    Absolute Data Group avatar
    9 posts
    Member since:
    May 2009

    Posted 21 Oct 2009 Link to this post

    I am getting a similar issue. In my case the RadComboBox is loaded from a user control and the very first time it is loaded into the page, it works correctly (Sets the selected value). However, on subsequent postbacks, the combo box loads with the value that it initially loaded with, even though the a new value has been selected. (I have tested this in the debugger).

    The code that I am using in the usercontrol looks something like this (you can see I have tried multiple ways to set this value correctly):

            Label1.Text = _PD.DisplayName 
            Dim tText As New RadComboBox() 
            tText.ID = _PD.Name 
     
            tText.Width = New Unit("200px"
            tText.LoadContentFile(_ConfigFile) 
            tText.EnableViewState = False 
            ''tText.SelectedIndex = tText.Items.FindItemIndexByValue(_PD.GetValue(_Node)) 
            tText.SelectedValue = _PD.GetValue(_Node) 
            ''tText.Items.FindItemByValue(_PD.GetValue(_Node)).Selected = True 
            PlaceHolder1.Controls.Add(tText) 

    However, oddly enough, if I do something that removes the user control after a post back, then trigger it to load again... the correct value will appear! It is only when the control being posted back is re-created that this behavior is present... which boggles my mind since I have implicitly turned off the viewstate.

    Not to sound sour her, but frankly I have been a little disapointed with using Telerik controls in usercontrols. This isn't the first little annoying bug that I have run into and I suspect the issue is client side scripting (usual culprit).




  6. Absolute Data Group
    Absolute Data Group avatar
    9 posts
    Member since:
    May 2009

    Posted 22 Oct 2009 Link to this post

    I changed my code to use the normal ASP.NET dropdown control and it works flawlessly :(

            Dim _DD As New DropDownList() 
            _DD.Width = New Unit("200px"
            _DD.ID = _PD.Name 
            _DD.EnableViewState = False
            Dim _Doc As XmlDocument = New XmlDocument() 
            _Doc.Load(Server.MapPath(_ConfigFile)) 
     
            Dim _ItemList As XmlNodeList = _Doc.SelectNodes("//Item"
     
            For Each _Item As XmlElement In _ItemList 
                Dim _LI As New ListItem(_Item.GetAttribute("Text"), _Item.GetAttribute("Value")) 
                _DD.Items.Add(_LI) 
            Next 
     
            _DD.SelectedValue = _PD.GetValue(_Node) 
     
            PlaceHolder1.Controls.Add(_DD) 

    Which leads me to ask... what the heck is going on with the RadComboBox? I checked every single value and as far as I can tell everything appears to be set correctly, but when the text box renders client side, the selected value always resets to the value selected the first time the control loads.

  7. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 26 Oct 2009 Link to this post

    Hi John Martinez,

    I believe the best way to answer your question is to reproduce the problem locally first. Please open a support ticket and attach a running project there.
    Thanks

    All the best,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Ryan
    Ryan avatar
    2 posts
    Member since:
    Feb 2009

    Posted 16 Jun 2011 Link to this post

    Hello Telerik Team,

    I am having this same (almost exact) problem, was there ever a solution to this issue?? The thread just died with no resolution...

    Thank you.
  9. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 20 Jun 2011 Link to this post

    Hello Ryan,

    Please specify what exactly is the problem you are experiencing and provide information on the particular implementation so we could help you out. 

    Greetings,
    Dimitar Terziev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  10. Dave
    Dave avatar
    13 posts
    Member since:
    Jun 2011

    Posted 12 Jul 2011 Link to this post

    I am having this issue as well when the combobox is inside a user control. See my recent post about ComboBox.Text not showing the selected item text. Please fix this...
  11. Dave
    Dave avatar
    13 posts
    Member since:
    Jun 2011

    Posted 12 Jul 2011 Link to this post

    Is there a known problem in this area or not? Thanks...
  12. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 14 Jul 2011 Link to this post

    Hello Dave,

    I've already responded to your problem in this forum thread here. In case this is a different issue, please accept my apologies and provide me with more information about the implementation  of your scenario.

    All the best,
    Dimitar Terziev
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  13. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 18 Apr 2012 Link to this post

    Hello all,

    I got exactly the same behaviour:
    http://www.telerik.com/community/forums/aspnet-ajax/combobox/combobox-selectedvalue-not-working.aspx#977218 

    The combo is part of a few controls being loaded dynamically, a RadNumericTextBox, a RadDatePicker and a RadComboBox
    All works fine. Data is loaded like ecpercted. Then, I change the sel item of the combo. On postback controls are loaded (init) with old values(thats ok, from the init event, before viewstate is placed), then the selectedIndexChanged is triggered (fine), the controls are rebuilded, and I can see the right values being passed to the combo (and the others) but when done, the selectedvalue is trhe prev value and not the value I just selected while the other changes are still correct...

    This all happens in a single page app whith dynamically loaded usercontrols.
    ' Text input for figure source
    Dim rcb As New Telerik.Web.UI.RadComboBox
    With rcb
        .ID = "Input_FOID" & FOIdx & "_Source"
        .Items.Clear()
        .Items.Add(New Telerik.Web.UI.RadComboBoxItem("(Onbekend)", "(Onbekend)"))
        .Items.Add(New Telerik.Web.UI.RadComboBoxItem("Interne cijfers", "Interne cijfers"))
        .Items.Add(New Telerik.Web.UI.RadComboBoxItem("Concept cijfers accountant", "Concept cijfers accountant"))
        .Items.Add(New Telerik.Web.UI.RadComboBoxItem("Gecons. concept cijfers accnt", "Gecons. concept cijfers accnt"))
        .Items.Add(New Telerik.Web.UI.RadComboBoxItem("Officiële vennootsch. cijfers", "Officiële vennootsch. cijfers"))
        .Items.Add(New Telerik.Web.UI.RadComboBoxItem("Officiële gecons. cijfers", "Officiële gecons. cijfers"))
        .Items.Add(New Telerik.Web.UI.RadComboBoxItem("KvK/D&B cijfers", "KvK/D&B cijfers"))
        .DropDownWidth = New Unit("220px")
        .MarkFirstMatch = True
        .Enabled = (ent_FinancialOverview.Locked Is Nothing)
        .Width = New Unit("147px")
        .ToolTip = "Source of figures"
    End With
    rcb.SelectedValue = ent_FinancialOverview.Source
    'or...
    rcb.SelectedIndex = rcb.FindItemByText(ent_FinancialOverview.Source).Index
    Td.Controls.Add(rcb)
    There is no databinding.

    Erik
  14. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 23 Apr 2012 Link to this post

    Hi Erik,

    I've made a sample page using the provided code snippet and everything is working properly on my side. The SelectedValue of the RadComboBox is the right one once a post-back occurs. I'm sending the sample page which I've been testing with so you could inspect it locally. The version of the controls which is
    2012.1.411.

    Greetings,
    Dimitar Terziev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  15. King Du
    King Du avatar
    12 posts
    Member since:
    Jun 2005

    Posted 01 Oct 2012 Link to this post

    I am seeing the same exact problem, was anyone able to workaround it?

    -pg
  16. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 02 Oct 2012 Link to this post

    Hello PG,

    I did not check any futher, I just replaced the combo with a MS Combobox because I did not have the time to investigate. (I still do not... )

    Regards,

    Erik
  17. King Du
    King Du avatar
    12 posts
    Member since:
    Jun 2005

    Posted 02 Oct 2012 Link to this post

    Thanks for the response Erik, I ended up creating a very simple project which reproduces my problem and opened a support ticket. Doesn't look like I can attach the project to this thread so you can see it but I will let you know once I hear back from Telerik.

    -pg
  18. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 02 Oct 2012 Link to this post

    That's great PG! And please keep me informed!

    Erik
  19. David
    David avatar
    2 posts
    Member since:
    Jan 2013

    Posted 31 Jan 2013 Link to this post

    I´m experience the same problem! I´m on a tight deadline and this is a real bump in the road, feels this is a standard feature that should not be a problem... I´m not using a usercontrol just a standard .aspx. It´s running in a sharepoint project thou.

    ASPX:
     
    <telerik:RadComboBox ID="rcbX" runat="server" DataValueField="Id" AllowCustomText="false"
        EnableLoadOnDemand="true" OnClientSelectedIndexChanged="ClearYComboBox"
        DataTextField="Namn" EmptyMessage="Choose X">
        <WebServiceSettings Method="GetAllX" Path="/X.asmx" />                   
    </telerik:RadComboBox>
     
    Codebehind:

    Page_Load:
            private void LoadAllX()
            {
                try
                {
                    var svc = new XService();
                    _X = svc.GetAllX();
     
                    rcbX.DataSource = _X;
                    rcbX.DataBind();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
     
            private void BindObject()
            {
                 rcbX.SelectedValue = _object.X.Id.ToString();
            }
  20. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 31 Jan 2013 Link to this post

    Hello David and Telerik,


    I'm also curious about a solution.

    PG created a sample problem project and created a support ticket. 

    How did that work out?


    Regards,

    Erik
  21. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 05 Feb 2013 Link to this post

    Hi Erik,

    There had been two solution provided in the support ticket opened by PG. The first one was to create the RadComboBox in the page init event instead of the page load. The second one was to change the SelectedValue after the control is added to the controls collection of the page. The same page used in the support ticket is attached for reference.

    All the best,
    Dimitar Terziev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  22. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 15 Feb 2013 Link to this post

    Thanks Dimitar.

    Had the problem today again. It does seem logical to load items on init, because of the viewstate: I now had a combobox in a radgrid edit form on a usercontrol. The usercontrol is dynamically loaded. When the combobox loads elements on load, I can imagine the selectedValue property to be reset... Doing it in the init of the combobox loads the elements before the viewstate is put back.

    Erik
  23. Timothy
    Timothy avatar
    2 posts
    Member since:
    Jun 2012

    Posted 26 Jul 2013 Link to this post

    I believe that I've found a solution to this exact problem, at least in my situation. 

    Before you set the .SelectedValue call the .ClearSelection() method.  In my case, where the combo box is tied to an object data source on the page, this caused the selected value to actually update on EVERY attempt.

    Assume you have a combo box named called radCombo1

    radCombo1.ClearSelection()
    radCombo1.SelectedValue = "TheOneIWant"
  24. Jennifer
    Jennifer avatar
    1 posts
    Member since:
    Jan 2009

    Posted 02 Dec 2013 Link to this post

    .
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017