Selected value is empty after postback

8 posts, 0 answers
  1. Sarani Ravindran
    Sarani Ravindran avatar
    6 posts
    Member since:
    May 2010

    Posted 21 Oct 2011 Link to this post

    Hi,

    Please provide us the solution for the following scenario.

    we are having 2 combo boxes in our page as below

    <telerik:RadComboBox Font-Names="Verdana" Skin="WebBlue" EmptyMessage="Select One" Height="200px"
                                            AllowCustomText="true" Filter="contains" MarkFirstMatch="false" EnableScreenBoundaryDetection="false"
                                            AutoPostBack="False" EnableLoadOnDemand="False" Width="95%" runat="server" CssClass="dropdown"
                                            ID="cbo1" OnClientBlur="OnClientBlurAdd" OnClientKeyPressing="clientKeyPressingAdd"
                                             OnClientDropDownOpening="ClientDropDownOpeningAdd">                                          
                                        </telerik:RadComboBox>

    Second combo box:

               <telerik:RadComboBox Font-Names="Verdana" Height="200px" Skin="WebBlue" EmptyMessage="Enter 3 or more characters to search"
                                            AllowCustomText="true" Filter="contains" MarkFirstMatch="true" EnableScreenBoundaryDetection="false"
                                            Width="350px" runat="server" CssClass="dropdown" ID="cboPatient" OnClientBlur="OnClientBlurPatient"  HighlightTemplatedItems = "True"
                                            OnClientKeyPressing="clientKeyPressingPatient" OnClientSelectedIndexChanged="ClientSelectedIndexChangedPatient"
                                            OnClientDropDownOpening="ClientDropDownOpeningPatient" EnableLoadOnDemand="true">
                                              <HeaderTemplate>
                                                <table  width = "100%">
                                                    <tr>
                                                        <td align = "left" style ="font-family: Arial, Verdana, Sans-Serif; font-size:12px; font-weight:bold; width:60%">
                                                            Clinic
                                                        </td>
                                                        <td align = "left" style ="font-family: Arial, Verdana, Sans-Serif; font-size:12px; font-weight:bold; width:40%">
                                                            Patient
                                                        </td>
                                                    </tr>
                                                </table>
                                             </HeaderTemplate>
                                             <ItemTemplate>
                                                    <table width = "100%">
                                                            <td align = "left" style ="font-family: Arial, Verdana, Sans-Serif; font-size:11px;width:60%">
                                                                 <%# DataBinder.Eval(Container.DataItem, "ClinicName") %>
                                                            </td>                                                        
                                                            <td align = "left" style ="font-family: Arial, Verdana, Sans-Serif; font-size:11px;width:40%">
                                                                 <%# DataBinder.Eval(Container.DataItem, "PatientLastName") %>
                                                            </td>
                                                    </table>
                                            </ItemTemplate>
                                        </telerik:RadComboBox>

    and the second will be filled based on the selected value of first one. And here we are always getting cbo1.SelectedValue is empty.
    but i am able to get the value here on the "OnClientBlur" event of cbo1.

    function OnClientBlurAdd(sender, eventArgs)
        {
             myMultipleParametersHandlerAdd(sender, eventArgs);
        }
      
        function myMultipleParametersHandlerAdd(combo, eventArgs)
        {
            var item=combo.get_highlightedItem();
            if(item !=null)
            {
                combo.set_text(item.get_text());
                combo.set_value(item.get_value());     ///i am able to get the value here        
            }
            else
            {              
                combo.clearSelection();
                combo.set_emptyMessage("Select One");           
                       
            }
        }

    what can be the issue?

    Thank you,
    Saranya.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Oct 2011 Link to this post

    Hello Saranya,

    You can try the following javascipt in OnClientSelectedIndexChanged event. OnClientBlur event is called when the object loses the input focus.

    JS:
    <script type="text/javascript">
     function OnClientSelectedIndexChanged(sender, args)
    {
      var item = sender.get_selectedItem().get_text();
      if (item != null)
       {
          alert(item);
       }
         
    }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sarani Ravindran
    Sarani Ravindran avatar
    6 posts
    Member since:
    May 2010

    Posted 25 Oct 2011 Link to this post

    Hi Princy,

    Yes, I have checked as you specified. i am getting the value as well as the selected text. But still the cbo1.SelectedValue is empty.

    Thanks,
    Saranya.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Oct 2011 Link to this post

    Hello Saranya,

    I have tried to reproduce the issue but no avail. You can make sure that the Value field of RadComboBox is set.

    Thanks,
    Princy.
  6. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 26 Oct 2011 Link to this post

    Hi Sarani,

    You should bind some information from the data source to the Value field of your items in order to be able to retrieve it on the server.

    Regards,
    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
  7. Rahul
    Rahul avatar
    39 posts
    Member since:
    Jan 2014

    Posted 11 Jan 2014 Link to this post

    Hi,Dimitar Terziev
                  How set the empty value to combo box after page postaback.

    Thanks Rahul
  8. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Jan 2014 Link to this post

    Hi  Rahul,

    Please have a look into the following code snippet to set the EmptyValue to RadComboBox after PostBack.

    JavaScript:
    <script type="text/javascript">
        function pageLoad() {
            var combo = $find("<%= RadComboBox1.ClientID %>");
            combo.clearSelection();
            combo.set_text(" ");
        }
    </script>

    Let me know if you have any concern.
    Thanks,
    Princy.
  9. Rahul
    Rahul avatar
    39 posts
    Member since:
    Jan 2014

    Posted 12 Jan 2014 Link to this post

    Hi Princy,
                   Thanks for help its work..
    Thanks
    Rahul
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017