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

Case Sensitive Bug

2 Answers 190 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Silver
Top achievements
Rank 1
Silver asked on 13 Dec 2011, 03:44 AM
hi, i have a combobox with filtering, i want to make sure that the text entered in combobox is item in list so i'm using SelectedValue method. Lets say i have database with ID : CUST01, when i type "CUST01" in combobox and hit check button it displays correctly "Item in list", but when i type "cust01" in combobox it displays "not item in list". I didn't turn on the case-sensitive property, neither did i have allowed custom text property. I'm using 2011 Q1 version, i don't know if this problem exist in the latest version, code belows

ASPX
<telerik:RadComboBox ID="cboCust" Runat="server" Width="178px"
    DropDownWidth="500px" HighlightTemplatedItems="True"
    EmptyMessage="Select Customer" EnableLoadOnDemand="True" Filter="Contains"
    Height="250px" MarkFirstMatch="True" AutoPostBack="True">
    <HeaderTemplate>
        <table style="width:415px; text-align:left">
            <td style="width:50px;">ID</td>
            <td style="width:200px;">Name</td>
            <td style="width:200px;">Address</td>
        </table>
    </HeaderTemplate>
    <ItemTemplate>
        <table style="width:415px; text-align:left">
            <td style="width:50px;">
                <%# DataBinder.Eval(Container.DataItem, "ID")%>
            </td>
            <td style="width:200px;">
                <%# DataBinder.Eval(Container.DataItem, "Name")%>
            </td>
            <td style="width:200px;">
                <%# DataBinder.Eval(Container.DataItem, "Address")%>
            </td>
        </table>
    </ItemTemplate>
</telerik:RadComboBox>

VB
Protected Sub cboCust_ItemsRequested(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles cboCust.ItemsRequested
    cSQL = "SELECT * FROM Customer"
    With cboCust
        .DataSource = FillDataset(cSQL)
        .DataTextField = "ID"
        .DataValueField = "ID"
        .DataBind()
    End With
End Sub
 
Protected Sub btnCheck_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCheck.Click
    If cboCust.SelectedValue = "" Then
        lblMsg.Text = "Not item in list"
    Else
        lblMsg.Text = "Item in list"
    End If
End Sub

2 Answers, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 13 Dec 2011, 06:44 PM
Hello Silver,

The values set to the RadComboBox's items are case sensitive as their role is to uniquely represent every item in the item's collection. This also is the case with the Text properties of the items because they act as values when there are no such defined for the items.

You could, however, implement a personal search-item-by-text or search-item-by-value method, which could consist of a single loop trough all the items of the RadComboBox in which you could check for a text equality of two lowered strings, as in the code-block below:
foreach (RadComboBoxItem item in RadComboBox1.Items)
{
    if (item.Text.ToLower() == RadComboBox1.Text.ToLower())
    {
        //item found.
    }else {
        //item not found
    }
}

I hope this is helpful.

Kind regards,
Ivana
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
Silver
Top achievements
Rank 1
answered on 14 Dec 2011, 02:41 AM
Hi Ivana, at the meantime i know 2 solutions, the first is as what you replied, the second is selecting those item (checking) through database, but i simply want a simple item checking (i mean faster processing speed). I suggest telerik team to add something like "non case-sensitive selectedvalue" or some function like "combobox.isiteminlist" in the future, best regards..
Tags
ComboBox
Asked by
Silver
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Silver
Top achievements
Rank 1
Share this question
or