Problem with Autocomplete extender CompletionSetCount

Last post 08-30-2008 11:40 AM by YairNevet. 4 replies.

Sort Posts:

  • Problem with Autocomplete extender CompletionSetCount

    06-27-2007, 2:50 AM

    Hi All,

          Am trying to use the autocomplete extender to suggest the users when they type  data.Basically the data gets fetched from database through a web service.

         This is my autocompleteextender properties

           

    <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtasset" ServicePath="MM_AutoCompleteWebService.asmx" ServiceMethod="GetAssetData" MinimumPrefixLength="1" CompletionSetCount="10" EnableCaching="false"></cc1:AutoCompleteExtender>

    and this is my web method

    [WebMethod]

    public string[] GetData(string prefixText, int count)

    {

    List<string> mylist=new List<string>();

     

    SqlDataReader dreader = mycomm.ExecuteReader(); while (dreader.Read())

    {

    string strtemp = Convert.ToString(dreader["szuserfirstname"]);

    mylist.Add(strtemp);

    }

    return mylist.ToArray();

     

    }

      Now i have specified my CompletionSetCount to be 10 but still when the results are getting displayed its very much more than 10.The number of records in my table is huge and i just want to restrict the number of entries getting displayed in the UI.Kinldy let me know how to do this.

        Also can anyone tell me how to improve performance with this.Since the data is huge when i start typing it takes little time to get me the results.I basically use a stored procedure to get the results.

     

    Thanks,

    Ravi

      

     

     

     

     

  • Re: Problem with Autocomplete extender CompletionSetCount

    06-27-2007, 3:18 PM
    Answer
    • Contributor
      2,610 point Contributor
    • kirtid
    • Member since 11-18-2006, 12:41 AM
    • Redmond
    • Posts 658
    • AspNetTeam

    The CompletionSetCount is a parameter passed the webservice method or pagemethod and it needs to respect that. You should trim your number of results to be equal to count and then return them.

    Kirti Deshpande
    Program Manager, Silverlight and ASP.NET AJAX
    Microsoft

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Problem with Autocomplete extender CompletionSetCount

    06-28-2007, 1:05 AM

    Kindly can you let me know how to trim my results to that count.The web method does not seem to respect the count value and i need to resolve this.

    Thanks,

     Ravi 

     

     

  • Re: Problem with Autocomplete extender CompletionSetCount

    06-28-2007, 1:44 AM
    • Contributor
      2,610 point Contributor
    • kirtid
    • Member since 11-18-2006, 12:41 AM
    • Redmond
    • Posts 658
    • AspNetTeam

    You need to change it to return the number of results equal to count.

     

    Kirti Deshpande
    Program Manager, Silverlight and ASP.NET AJAX
    Microsoft

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Problem with Autocomplete extender CompletionSetCount

    08-30-2008, 11:40 AM
    • Member
      94 point Member
    • YairNevet
    • Member since 03-31-2007, 6:07 AM
    • Yavne, Israel
    • Posts 175

    Hi,

    Your sql query should look like this example(notice to the TOP clause):

    string selectString = "SELECT DISTINCT TOP " + count.ToString() + " Country from Countries WHERE Country LIKE '" + prefixText + "%'";

     

    Yair Nevet

    Yair Nevet
    Microsoft MCAD.NET
Page 1 of 1 (5 items)