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

Value Not Returned On Second Selection

2 Answers 81 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 17 May 2011, 07:36 PM
Hello,
   We are currently using a RadComboBox with loadOnDemand within our MasterPage.   The SelectedValue of the ComboBox and the SelectedText are properly returned to the SelectedIndexChanged Event when a combobox item is selected from the drop down for the first time but not upon the second selection.  To be more clear.  If you have 3 ComboboxItems (in our case "projects")  : Item 1, Item 2 and Item3.  If Item 1 is selected the SelectedIndexChangedEvent works as expected.  Both the Text and Value of the event are populated in the event handler as expected, If Item 2 is selected the same expected behavior occurs.  If however a user were to RE select Item 1 after previously selecting Item 1 during the same session then ONLY the Text of the event handler is populated in the event value is not populated.  To make matters slightly more confusing the SelectedValue of the combo Box is also returning an empty string only on the reselection but appears to be working properly for the initial selection..  I have no idea why everything seems to be working fine for the first iteration of a selection but not the second.  Any advice would be sincerely appreciated.  Relevant Code Below:

C#

  protected void rcbCurrentProject_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
                     
            var projects = FluxPermissionManager.GetUserProjectAccess(Page.User.Identity.Name).Select(lkj => new { name = lkj.name, testProjectID = lkj.testProjectID });
            rcbCurrentProject.DataSource = projects.ToList();
            rcbCurrentProject.DataBind();

            e.Message = "Displaying All Accessible Projects";            
        }



    protected void rcbCurrentProject_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            try
            {
        //e.Text Is populated Properly.... no issues
        string projectName = e.Text
        
        //e.Value returns an empty string following the second time selected.
                int val = Int32.Parse(e.Value);

        . . . ...
          }

       }


ASPX

    <telerik:RadComboBox ID="rcbCurrentProject" runat="server" ErrorMessage="None Selected" EnableLoadOnDemand="true"
                                ShowMoreResultsBox="false" AutoPostBack="true" EnableVirtualScrolling="false" OnPreRender="rcbCurrentProject_PreRender"
                                DataTextField="name" DataValueField="testProjectID" OnItemsRequested="rcbCurrentProject_ItemsRequested"  
                                MarkFirstMatch="true" Filter="Contains" AllowCustomText="false" OnSelectedIndexChanged="rcbCurrentProject_SelectedIndexChanged"
                                OnClientDropDownOpening="cleanProjectDefaultSelection">
                            </telerik:RadComboBox>


      function cleanProjectDefaultSelection(sender, args) {
            if (sender.get_text() != "") {
                sender.set_text("");
                sender._filterText = "";
                sender.requestItems("");
            }
        }

2 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 20 May 2011, 03:10 PM
Hello Andrew,

I used the code provided to create a sample and to reproduce the issue - but on my side RadComboBox works properly and I am able to get the selected text and value correctly. Please find the sample attached.
I do not know what the implementation of OnPreRender event handler that you have created is, but on my opinion your code is all right.
Sometimes a similar issue related to item selection can occur if there are RadComboBox items with same values populated in RadComboBox - you can find more details about this topic here.
Please check if there are items with same values populated in the RadComboBox.

Best wishes,
Kalina
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.

0
Andrew
Top achievements
Rank 1
answered on 26 May 2011, 07:24 AM
Thanks for your response.  It was an issue in the PreRender Event that was utlimately causing the issue.  In the PreRender Event we were inserting a supposedly temporary combobox Item, so the text of the ComboBox always reflected the currently selected Item.  Because we were under the impression that this item was only temporary and getting trashed on the ItemsRequestedEvent we were inserting a blank value.  Your advice pointed me in the right direction and everything is working properly.  Thanks!
Tags
ComboBox
Asked by
Andrew
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or