Search code examples
asp.netstringajaxcontroltoolkit

Filter Suggestions from AutoComplete control


[WebMethod]
        public string[] GetSuggestions(string prefixText, int count)
        {
            List<string> responses = new List<string>();
            //List<string> lst = new List<string>();
            int str=0;
            IngresConnection conn = new IngresConnection(constr);
            conn.Open();
            IngresCommand cmd = new IngresCommand("select name from addresses", conn);
            IngresDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {

                if (reader.GetValue(0).ToString().Contains(prefixText) && str<count)
                {
                     responses.Add(reader.GetValue(0).ToString());
                    str++;
                }
            }

I'm using above code to pass the filtered text to the AutoComplete Ajax control.what i need is when i type on the textBox it should populate the suggestions which begins with the Prefix.currently the it populates suggestions where the Prefix contains any where with in the string


Solution

  • got the solution

    reader.GetValue(0).ToString().StartsWith(prefixText)