ComboBox and EmptyMessage

2 posts, 0 answers
  1. Michael
    Michael avatar
    12 posts
    Member since:
    May 2008

    Posted 26 Mar 2009 Link to this post

    I'm using a radcombobox to populate items  from a database on demand.  All works well except for when EmptyMessage is set

    The Problem:

        On the first attempt to drop the box down, it displays no matches and nothing comes up in the list.  The second dropdown attempt everything works perfectly.  Happens only when the EmptyMessage property is set.  I'm stumped.

    Here is what my code looks like:

    .aspx and javascript

    <telerik:RadComboBox ID="cboCities" runat="server" AutoPostBack="True" EnableLoadOnDemand="True"   
                                                                EnableVirtualScrolling="True" Height="200px" MarkFirstMatch="True"   
                                                                OnItemsRequested="cboCities_ItemsRequested" Filter="None" ShowMoreResultsBox="True"   
                                                                Width="240px" Font-Size="X-Small" AllowCustomText="True"   
                                                                EmptyMessage="Type a city name" Skin="Black">  
                                                                <CollapseAnimation Duration="200" Type="OutQuint" /> 

    function OnClientItemsRequesting(sender,e)  

    Finally the codebehind:

    Protected Sub cboCities_ItemsRequested(ByVal sender As ObjectByVal e As RadComboBoxItemsRequestedEventArgs)  
            Dim sql As String = "Select cityCode,cityName,State,Lat,Long from s_CityMaster WHERE Cityname LIKE '%" + e.Context("CustomText").ToString() + "%' ORDER BY CityName" 
            Dim adapter As New SqlDataAdapter(sql, ConfigurationManager.AppSettings("BioDiasporaCS"))  
            Dim data As New DataTable()  
                Dim itemsPerRequest As Integer = 10  
                Dim itemOffset As Integer = e.NumberOfItems  
                Dim endOffset As Integer = itemOffset + itemsPerRequest  
                If endOffset > data.Rows.Count Then 
                    endOffset = data.Rows.Count  
                End If 
                If endOffset = data.Rows.Count Then 
                    e.EndOfItems = True 
                End If 
                Dim i As Integer = itemOffset  
                While i < endOffset  
                    cboCities.Items.Add(New RadComboBoxItem(data.Rows(i)("cityName").ToString(), data.Rows(i)("cityName").ToString()))  
                    i = i + 1  
                End While 
                If data.Rows.Count > 0 Then 
                    e.Message = [String].Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString())  
                    e.Message = "No matches" 
                End If 
                e.Message = "No matches" 
            End Try 
        End Sub 

    Can anyone help me with what I'm doing wrong? Thanks in advance.
  2. Simon
    Simon avatar
    2281 posts

    Posted 31 Mar 2009 Link to this post

    Hello Michael,

    Thank you for raising the issue.

    This is a bug which we are aware of and will fix with the upcoming Service Pack which is due to the end of this week.

    Kind regards,
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. DevCraft R3 2016 release webinar banner
Back to Top