Click here to Skip to main content
16,013,465 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am using autocomplete extender in my application.the control doesnt giving the values in textbox.And i am using webservice to get the values.can anyone tell me wats the issue in that...pls very urgent........

this my web method code and design code...

C#
[WebMethod]
   public string[] names(string prefixText,int count,string contextKey)
   {
       string sql = "SELECT * FROM familytwo Where Name like @prefixText";
       SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString.ToString());
       SqlDataAdapter da = new SqlDataAdapter(sql, conn);
       da.SelectCommand.Parameters.Add("@prefixText", System.Data.SqlDbType.VarChar, 50).Value = prefixText + "%";
       DataTable dt = new DataTable();
       da.Fill(dt);
       string[] items = new string[dt.Rows.Count];
       int i = 0;
       foreach (DataRow dr in dt.Rows)
       {
           items.SetValue(dr["Name"].ToString(), i);
           i++;
       }
       return items;
   }
Posted
Updated 12-Mar-12 6:13am
v3
Comments
ZurdoDev 12-Mar-12 10:19am    
What does happen is much more important than what does not happen.
Orcun Iyigun 12-Mar-12 12:19pm    
Do you have a autocompleteextender control in design which is assigned to that textbox? Something like <pre lang="c#"><asp:AutoCompleteExtender ID="AutoCompleteExtender1"
TargetControlID="txtTextbox" runat="server"
ServiceMethod="names" UseContextKey="True" /></pre>

1 solution

public string[] names(string prefixText,int count,string contextKey)
{
string sql = "SELECT * FROM familytwo Where Name like @prefixText";
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString.ToString());
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
da.SelectCommand.Parameters.Add("@prefixText", System.Data.SqlDbType.VarChar, 50).Value = prefixText + "%";
DataTable dt = new DataTable();
da.Fill(dt);
string[] items = new string[dt.Rows.Count];
int i = 0;
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["Name"].ToString(), i);
i++;
}
return items;
}
 
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