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

[Solved] Selectedvalue becomes empty

1 Answer 111 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
sathies
Top achievements
Rank 1
sathies asked on 10 Dec 2009, 12:36 PM
Hi,

<telerik:RadComboBox ID="RadComboBox2" EnableViewState="false" EnableItemCaching="true"
            EnableLoadOnDemand="true" Filter="Contains"   runat="server" onitemsrequested="RadComboBox2_ItemsRequested" >
        </telerik:RadComboBox>
<asp:Button ID="Button1" runat="server" Text="Ok" onclick="Button1_Click" />

protected void RadComboBox2_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
    {
        RadComboBox2.Items.Add(new RadComboBoxItem("--All--", "0"));
        RadComboBox2.Items.Add(new RadComboBoxItem("Accepted", "1"));
        RadComboBox2.Items.Add(new RadComboBoxItem("Not Accepted", "2"));
        RadComboBox2.Items.Add(new RadComboBoxItem("Pending", "3"));
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
      string s = RadComboBox2.SelectedValue;
    }


If we set true to "EnableLoadOnDemand" we are getting the following problem.

We are filling some values in the combobox. And on type some characters(accepted) the combobox gets filtered accordingly (refer attahced screen shot). Then without selecting the text (Accepted )in the combo press enter. while clicking the button "OK" the Selectedvalue for the entered character in the combobox becomes empty.

For example see the above code: Accepted is having value 1, this becomes empty on click of "OK" button. I think this problem is due to that the combobox is assuming the entered text as new item.

But both are same.How to solve this

Please help me

regards
sathies


1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 11 Dec 2009, 01:24 PM
Hi sathies,

Yes, this is the normal behavior of RadComboBox in this case, since after pressing Enter the custom text remains as it is and no Item is selected.

In order to receive the correct Item value you need to first select the Item. If you set MarkFirstMatch to true in your case you will achieve your goal.

All the best,
Simon
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.
Tags
ComboBox
Asked by
sathies
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or