hello everyone,
I am trying to use the autocomplete extender but it won't fetch the data. Why is it not working?
thank you for your advice.
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" ServiceMethod="SearchEmployeesByName"
MinimumPrefixLength="2" CompletionInterval="100" EnableCaching="false" CompletionSetCount="10"
TargetControlID="txtContactsSearch" runat="server">
</cc1:AutoCompleteExtender>
public partial class Controls_EmployeeByName : System.Web.UI.UserControl
{
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
protected void Page_Load(object sender, EventArgs e)
{
}
public static List<string> SearchEmployeesByName(string prefixText, int count)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager
.ConnectionStrings["CompanyInfoEventsConnectionString"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select ID, FullName from GpiEmployees where " +
"FullName 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["FullName"].ToString());
}
}
conn.Close();
return customers;
}
}
}
}