Click here to Skip to main content
15,920,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#



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" >




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
Posted
Updated 6-Nov-12 19:16pm
v2

1 solution

At first glance, try changing the parameter name.

public string[] GetEmpID(string contextKey)
 
Share this answer
 

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

  Print Answers RSS


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