Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everyone,
i've been googling all days to find the best way of how to create the autocomplete combobox in asp.net project.but i cant find an answer that i can understand.
the situation is I have a category list that user have to use dropdownlist to select the category.since the list of category is too long,i'm thinking of using autocomplete combobox which means user can either scroll down to choose the category or just search from the drop down list.help me please .... i need a complete tutorial of how to use this method.
Posted
Comments
choudhary.sumit 11-Dec-12 4:19am    
why dont u use a TextBox with autocompletesource=custom for this purpose? set autocompletemode to "suggest & Append" then it will be useful as you want!

you can use jquery UI
check this link
 
Share this answer
 
Go through this link. Using Ajax you can solve your problem.

Auto complete Textbox in asp.net using ajax and c#[^]
 
Share this answer
 
Take a textbox , goto its property, there you will see "autocompletesource" set it to custom. and "autocompletemode set as Suggest&append.
now in code behind:
C#
private void Form1_Load(object sender, EventArgs e)
{
 AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection();
 SqlDataReader dReader;
SqlConnection conn = new SqlConnection();
conn.ConnectionString = strConnection;
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText =
"Select distinct [Name] from [Names]" +
" order by [Name] asc";
conn.Open();
dReader = cmd.ExecuteReader();
if (dReader.HasRows == true)
{
while (dReader.Read())
namesCollection.Add(dReader["Name"].ToString());

}
else
{
MessageBox.Show("Data not found");
}
dReader.Close();


txtName.AutoCompleteCustomSource = namesCollection;

}
}
 
Share this answer
 
Check out following articles which explains how to create an auto-complete text-box from scratch
VB
ASP.NET(C#) : Autocomplete TextBox - Part 1

[^]

Explains how to use an autocomplete extender control created by Microsoft
VB
ASP.NET(C#) : Autocomplete TextBox - Part 2

[^]
 
Share this answer
 
 
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