Skip to content

Ajax AutoCompleteExtender Help

Priti Srivastava

Asked Sep 5, 2014, 1:34 AM EDT3 answers
Share
LinkedInX
i am using Ajax  AutoCompleteExtender in my project with a textbox. it work fine and return list of values. Can any help me to hand this list when list contain more than 10 item. i want to show only 10 items at one time with scrollbar.

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Ramu
    0
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


    <asp:ScriptManager ID="ScriptManager1" runat="server"
    EnablePageMethods = "true">
    </asp:ScriptManager>
     
    <asp:TextBox ID="txtContactsSearch" runat="server"></asp:TextBox>
    <cc1:AutoCompleteExtender ServiceMethod="SearchCustomers"
        MinimumPrefixLength="2"
        CompletionInterval="100" EnableCaching="false" CompletionSetCount="10"
        TargetControlID="txtContactsSearch"
        ID="AutoCompleteExtender1" runat="server" FirstRowSelected = "false">
    </cc1:AutoCompleteExtender>


    [System.Web.Script.Services.ScriptMethod()]
    [System.Web.Services.WebMethod]
    C#
    public static List<string> SearchCustomers(string prefixText, int count)
    {
        using (SqlConnection conn = new SqlConnection())
        {
            conn.ConnectionString = ConfigurationManager
                    .ConnectionStrings["constr"].ConnectionString;
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandText = "select ContactName from Customers where " +
                "ContactName like @SearchText + '%'";
                cmd.Parameters.AddWithValue("@SearchText", prefixText);
                cmd.Connection = conn;
                conn.Open();
                List<string> customers = new List<string>();
                using (SqlDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        customers.Add(sdr["ContactName"].ToString());
                    }
                }
                conn.Close();
                return customers;
            }
        }
    }
    0
  • 0
    thanks to reply ramu sir!
    but this is not correct answer of my query.
    I did it and the solution is




              > *
        CompletionListCssClass="productList"  EnableViewState="true" Enabled="true" TargetControlID="txtPurProName" MinimumPrefixLength="1" EnableCaching="true" CompletionInterval="1000" CompletionSetCount="1" ServiceMethod="GetProduct" runat="server">
    0
  • 0
    sir i am using oledb connection so plz post  code for oledbdatabase
    0