I need my textbox to autocomplete when the user types. The value should come from the database.
I am using the textchange property of the textbox.
protected void autocomplete(object sender, EventArgs e)
{
string query = "Select area,codes from tbl_pincode";
SqlConnection conn = new SqlConnection("Data Source=win2008-2;Initial Catalog=h1tm11;User ID=sa;Password=#1cub3123*;Persist Security Info=True;");
SqlCommand com = new SqlCommand(query, conn);
conn.Open();
SqlDataReader dr = com.ExecuteReader();
while (dr.Read())
{
zipcode.Text = dr.GetValue(0).ToString();
}
conn.Close();
}
But i m not getting the desired result.
Any ideas how to go about it?
You can use jQuery UI for autocomplete: http://www.dotnetcurry.com/ShowArticle.aspx?ID=515
Another option for ASP.NET autocomplete is AjaxControlToolkit: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx