Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Autoselection textbox not displaying the result from db

$
0
0

HI,

I have created an autoselection textbox in awebform like this
  <asp:ScriptManager ID="ScriptManager1" runat="server" />
                <asp:TextBox ID="txtSearch" runat="server" ></asp:TextBox>
                <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtSearch" ServicePath="~/WebService1.asmx" ServiceMethod="GetCountryInfo" MinimumPrefixLength="1" >
                </asp:AutoCompleteExtender>

And a webservice as follows which returns the country list from db

public string[] GetCountryInfo(string prefixText)
{
 //int count = 10;
 string sql = "Select * from tblCountry Where CountryName like @prefixText";
 string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["TestDatabaseConnectionString"].ToString();
 SqlDataAdapter da = new SqlDataAdapter(sql,connectionString);
 da.SelectCommand.Parameters.Add("@prefixText", 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["CountryName"].ToString(),i);
  i++;
 }
 return items;
}

When i type a letter in the textbox, the control is going to service method and it returns the result correctly ,but my problem is the result is not showing as a list in the textbox.Still the textbox is showing only the typed letter not the result from service method.

Can anybody pls help me in this
Thanks in advance
Nisha


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>