Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How to set autocomplete for a webservice in Asp.Net with C#? I have hosted a web service to fetch data based on a CustomerId which is passed as parameter. I want to set autocomplete for the CustomerId parameterfor a webservice in Asp.Net with C#
Posted
Comments
vikrant vaibhav 22-Jul-14 7:33am    
Please provide the code.

 
Share this answer
 
try this

C#
<pre lang="xml">[System.Web.Script.Services.ScriptMethod()]
    [System.Web.Services.WebMethod]
    public static List<string> GetCategory(string prefixText)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ToString());
        con.Open();
        SqlCommand cmd = new SqlCommand("select distinct product from ProductAdd where product like @Name+'%'", con);
        cmd.Parameters.AddWithValue("@Name", prefixText);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        List<string> Cid = new List<string>();
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            Cid.Add(dt.Rows[i]["product"].ToString());
        }
        return Cid;
    }



u want to call this method in client side in AutoCompleteExtender as ServiceMethod="GetCategory"

i hope this use full for you...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900