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

Selected value is empty after postback

7 Answers 329 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sarani Ravindran
Top achievements
Rank 1
Sarani Ravindran asked on 21 Oct 2011, 12:37 PM
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.

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Oct 2011, 02:02 PM
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.
0
Sarani Ravindran
Top achievements
Rank 1
answered on 25 Oct 2011, 09:47 AM
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.
0
Princy
Top achievements
Rank 2
answered on 25 Oct 2011, 10:47 AM
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.
0
Dimitar Terziev
Telerik team
answered on 26 Oct 2011, 12:32 PM
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
0
Rahul
Top achievements
Rank 1
answered on 12 Jan 2014, 05:39 AM
Hi,Dimitar Terziev
              How set the empty value to combo box after page postaback.

Thanks Rahul
0
Princy
Top achievements
Rank 2
answered on 13 Jan 2014, 04:44 AM
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.
0
Rahul
Top achievements
Rank 1
answered on 13 Jan 2014, 05:47 AM
Hi Princy,
               Thanks for help its work..
Thanks
Rahul
Tags
ComboBox
Asked by
Sarani Ravindran
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Sarani Ravindran
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Rahul
Top achievements
Rank 1
Share this question
or