Hi,
Auto Complete extender is not working properly in visual studio 2008.I am using the following code :-
<asp:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server" CompletionInterval="0"
CompletionListElementID="search" CompletionSetCount="12" EnableCaching="true"
MinimumPrefixLength="1" ServiceMethod="GetEmpID" ServicePath="~/WebService1.asmx"
ShowOnlyCurrentWordInCompletionListItem="true" TargetControlID="TextBox1" >
</asp:AutoCompleteExtender>
below is the webservice code:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetEmpID(string prefixText)
{
SqlConnection con = new SqlConnection("server=sushma-pc;user id=sa;password=secure2011;database=dbase");
DataSet ds = new DataSet();
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select Distinct EmpID from Tbl_EmpDetails where EmpID like @myParameter";
cmd.Parameters.AddWithValue("@myParameter", "%" + prefixText + "%");
try
{
con.Open();
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
}
catch
{
}
finally
{
con.Close();
}
dt = ds.Tables[0];
List<string> EmpID = new List<string>();
String dbValues;
foreach (DataRow row in dt.Rows)
{
dbValues = row["EmpID"].ToString();
dbValues = dbValues.ToLower();
EmpID.Add(dbValues);
}
return EmpID.ToArray();
}
}
I am not getting any kind of error though the list is not coming in the textbox.
Kindly share your ideas regarding the same