<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtenderserch" runat="server" TargetControlID="TextBox1"
ServiceMethod="GetCategory" MinimumPrefixLength="1"
EnableCaching="true" CompletionSetCount="12" ServicePath="~/ProductProfiling/ManageProduct.asmx"
ContextKey="1">
</cc1:AutoCompleteExtender>
This my web method
public string[] GetCategory(string prefixText, int count)
{
string var = prefixText.ToString() + "%";
List<string> items = new List<string>(count);
//string[] companyName = new string[query.ToList().Count];
//string str = "select Name,CategoryId from Category where Name like '" + var + "' and Level='0'";
string str = " select Name, CategoryId from Category where Name like '" + var + "'";
if (ObjCon.State != ConnectionState.Open)
{
ObjCon.Open();
}
ObjCmd = new SqlCommand(str, ObjCon);
ObjDReader = ObjCmd.ExecuteReader();
while (ObjDReader.Read())
{
items.Add(ObjDReader["Name"].ToString());
}
ObjDReader.Close();
ObjCmd.Dispose();
ObjCon.Close();
return items.ToArray();
}