Click here to Skip to main content
15,889,436 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
how to create writable and searchable dropdown list in my asp.net usin c# give me sample code please

thanks in advance....
Posted

i think thier is no writable ddl up to my knowledge....

but i will explain about the searchable dropdownlist...
First type....

when u took ddl from toolbox to form or webpage..just simply select it and go to the properties page... their u can find "combobox/drop down list" in tools... then simply rag it on to ur place...then go to the propertis their u can find items collection click on it n add ur items their what to want to see in ur dropdownlist.....
like
country: usa,uk,india like that

Second type....

serachable ddl menas u want to drop all the table content series to the ddl then simply use the below code:

con.Open();
SqlCommand cmd = new SqlCommand("select * from StateTable where CountryID="+CountryID, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
ddlState.DataSource = ds;
ddlState.DataTextField = "StateName";
ddlState.DataValueField = "StateID";
ddlState.DataBind();
ddlState.Items.Insert(0, new ListItem("--Select--", "0"));
if(ddlState.SelectedValue=="0")
{
ddlRegion.Items.Clear();
ddlRegion.Items.Insert(0, new ListItem("--Select--", "0"));
}
 
Share this answer
 
Comments
teja sai ravi 7-Nov-13 1:57am    
thanks for ur reply i need to search my drop down list by typing in drop down how can i do this even i tried by writing ListSearchExtender but it is not displaying what i typed i think i have to add a text box..but how to add and apply to dropdown
Member 13042781 15-Sep-17 23:43pm    
What's the ddlRegion in this
Use ajax combobox you will get this feature writable and searchable dropdownlist. Below some link's which will help you lot


Ajax ComboBox in ASP.NET



Ajax combobox
 
Share this answer
 
Comments
teja sai ravi 7-Nov-13 2:00am    
thanks for ur reply i know it but what iam trying is through dropdown list i want to search
please use an extender controllers which are available in AJAX controller

please go through the below link it maybe help full;.

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/DropDown/DropDown.aspx[^]
 
Share this answer
 
jQuery Searchable DropDown Plugin Demo
A jQuery plugin which extends normal dropdown (select) elements to be searchable.

http://jsearchdropdown.sourceforge.net/[^]
 
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