AutoComplete a DropDownList

Last post 08-30-2008 1:08 PM by varshacon. 3 replies.

Sort Posts:

  • AutoComplete a DropDownList

    02-29-2008, 7:27 PM
    • Member
      8 point Member
    • qbui66
    • Member since 10-14-2007, 11:22 PM
    • Posts 62

    Hi everyone,

    I'd like to create a drop down list with auto complete.  I'm using Visual Studio 2008 with C# and AJAX.  Is there a way to do it?

     The drop down list is the list of customer code from a database.  I'm able to have the drop down list by bounding it to the database result but don't know how to have the auto complete function working.

    Any help would be greatly appreciated.

    QBui

  • Re: AutoComplete a DropDownList

    03-01-2008, 6:16 AM
    Answer

    A text box will get  Autocomplete  values from a webmethod.Follow the example. 

      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" UseContextKey="True"
                    ServiceMethod="GetCompletionList" TargetControlID="TextBox1" MinimumPrefixLength="3"
                    CompletionSetCount="3" EnableCaching="true">
                </cc1:AutoCompleteExtender>

     


        [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
        public static string[] GetCompletionList(string prefixText, int count, string contextKey)
        {
            string[] st = new string[4];
            st[0] = prefixText + "hai";
            st[1] = prefixText + "hai";
            st[2] = prefixText + "hai";
            st[3] = prefixText + "hai";
            return st;
        }

    Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.
  • Re: AutoComplete a DropDownList

    03-01-2008, 4:35 PM
    • Member
      8 point Member
    • qbui66
    • Member since 10-14-2007, 11:22 PM
    • Posts 62

    Thanks for your reply but I don't think I want to autocomplete a text box, I'd like to have a drop down list which already bound to a dataset and then the user can just enter the first two letters and it just autocomplete whatever it is in the bounded dataset. 

    Probably this is impossible to have a drop down list with autocomplete.

    Qbui

  • Re: AutoComplete a DropDownList

    08-30-2008, 1:08 PM
    • Member
      13 point Member
    • varshacon
    • Member since 05-05-2008, 7:00 AM
    • Posts 39

    I too need it urgently. Any help on 'AutoComplete a DropDownList' please.

Page 1 of 1 (4 items)