Click here to Skip to main content
15,886,026 members
Everything / Drop-down

Drop-down

drop-down

Great Reads

by Avelino Ferreira
The easiest way to implement the ToolStripControlHost and ToolStripDropDown classes, in a UserControl, in order to display a Container/Control beyond the limits of its Parent Container and Parent Form, with very few lines of code. Let's uncomplicate ...
by Puja Jagani
Using jTable instead of drop-down list.
by murtaza dhari
A generic dropdown control using LINQ to SQL and Entities using Reflection
by ASP.NET Community
Every time user’s complaints me about page scroll issues. For example: If a lengthy page having a dropdown list with AutoPostBack = true at bottom of

Latest Articles

by Robert Gustafson
Extended versions of ListBox and ComboBox controls which allow image, font, and colors for an individual item--along with multi-row/aligned-tab support for list box--and drop-down-list mouse-events/horizontal-scrollbar and custom drop-down buttons for combo box
by Evoluteur
A web color picker which looks like the one in Microsoft Office 2010
by Igor Krein
C# Extensions API for Entity Framework intended to simplify usage of drop-down lists, comboboxes and alike
by Avelino Ferreira
The easiest way to implement the ToolStripControlHost and ToolStripDropDown classes, in a UserControl, in order to display a Container/Control beyond the limits of its Parent Container and Parent Form, with very few lines of code. Let's uncomplicate ...

All Articles

Sort by Score

Drop-down 

3 Aug 2016 by Avelino Ferreira
The easiest way to implement the ToolStripControlHost and ToolStripDropDown classes, in a UserControl, in order to display a Container/Control beyond the limits of its Parent Container and Parent Form, with very few lines of code. Let's uncomplicate ...
28 Aug 2011 by Wonde Tadesse
Just take a look at this example. Populate Cascading DropDownList based on selection of other dropdown ASP.NET[^]
19 Jul 2016 by Puja Jagani
Using jTable instead of drop-down list.
8 Feb 2011 by Monjurul Habib
Catch it on ListView ItemDataBoundPlesae dont copy and paste, try to understand.example.aspx DataSourceID="SqlDataSource1" ItemPlaceholderID="SqlItemContainer"...
12 Jun 2011 by Sandeep Mewara
Yes, very much possible. For example, if you select 'Others' as an option in the select then a textbox needs to be shown where one can fill any description of other if needed. You need to do:1. Attach a Javascript 'onchange' handler for the select2. Whenever anything is selected the...
7 Jul 2011 by Sergey Alexandrovich Kryukov
First of all, even if you implement such behavior, it cannot be called "validator". A "validator" is something which validates data after it is entered, but you want to filter out the input (selection) itself.I fear to say such behavior is too far from expected UI behavior and would be very...
28 Aug 2011 by Abhijit Jana
This is one of the mist frequent question asked over here. Check this outhttp://www.codeproject.com/search.aspx?q=cascading+dropdown&x=0&y=0&sbo=qa&usfc=false[^]
22 Apr 2012 by Mohamed Mitwalli
Hi Check this Example will Guide you protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString)) ...
15 May 2012 by Steve Echols
I think you want to do something like this instead (assuming you don't have viewstate turned off): If Not Page.IsPostBack Then Dim sqlCust As String = "SELECT CUSTCODE_T, CUSTNAME_T FROM CUST_MASTER" Dim dt As DataTable =...
30 Jun 2012 by AshishChaudha
Follow the below codedropList1.Items.Insert(0, new ListItem(String.Empty, String.Empty));dropList1.SelectedIndex = 0;make it answer if this is your solution. dont forget to rate the solution.Thanks
1 Aug 2012 by Prasad_Kulkarni
ASP.NET cascading drop-down-list (CSASPNETCascadingDropDownList)[^]CascadingDropDown Demonstration[^]Cascading DropDownList in ASP.NET MVC[^]Creating Cascading DropDownLists in ASP.Net[^]Using CascadingDropDown with a Database[^]Get more on CP Search[^]
16 Aug 2012 by I.explore.code
1) Limit the number of elements shown in the combo box, otherwise it would defeat the usability of the control if the user has to browse through all that data to get to the item they want. For limiting data, you can try loading 5 items or 10 items at a time and when the user scrolls past the...
16 Aug 2012 by Santhosh Kumar Jayaraman
Why do you want to display 20000 records in Combobox?? Do you think user will be scrolling down and check 20000 records to select one record?Try something else like autocomplete textbox or gridview with paging.its very bad idea to load 20k records in a combobox.. Even if we make some...
27 Oct 2013 by Mahesh Bailwal
As you are adding values on client side you won't be able to get selected value through ddl.selectedvalue as sever is not aware about new values added through Jquery. So in this case you need to fetch value from Request object like belowstring seletVal = Request[ddl.UniqueID]
4 Aug 2020 by TheRealSteveJudge
First of all you must cast "sender" which is just an object to "ComboBox". Then you must get "SelectedValue". Finally you must get the files that are in the selected directory and use it as data source for the ListBox. private void...
1 Jun 2010 by Samanvay
For this you need to pass Dropdownlist value to XSL using parameter and based on param value which you have received in XSL apply xsl:sort statement. Roughly you need to do following C# CODEXslCompiledTransform tras = new XslCompiledTransform();XsltArgumentList argList = new...
7 Dec 2010 by Amit Kumar Tiwari
What you have done is correct.But from the optimization point of view I think that every time when the row binding will occur, your function "GetYears" will be executed.What the best I can think of is, make a property (store value in viewstate) which gets initialized at page load with...
22 Jan 2011 by Henry Minute
If your ComboBox is part of a ComboBoxColumn then Manfred's solution might not work.Take a look at this[^] thread on MSDN.Social (Scroll down until you see the first message from 'mcassoc') and in that message take note of the event handler for the EditingControlShowing event. Using that...
5 May 2011 by day_hard
Need help plz please, i have two DropDownLists (nested). I use SelectedIndexChanged event to populate the second DropDownList.So, the problem is that i need to save the both values of DropDownLists to a database, i can do easily for the first DropDownList , but how to capture the second...
5 May 2011 by Karthik. A
You are more or less there. Just set the AutoPostBack property of the second drop down also to true and handle the selected index changed event. Now you can the selected values for both the drop downs and add it to the database. If this is not what you intended to achieve, sorry. Please...
3 Aug 2011 by Herman<T>.Instance
look here Multi-color DropDownList using C#[^]
10 Aug 2011 by sujit0761
--Choose one-- Option 1 Option 2 Add a value field to each list item. And in the required fiels validator set the Initial Value to 0. This will help you to validate your dropdown and the "Choose one..." will not be sent to DB.Hope this will help you!!!
5 Jan 2012 by Sergey Alexandrovich Kryukov
Please see my comment. Your approach to the question is wrong. You need to provide more complete information.Now, it looks like you gvddlRequestStatus becomes null, because you FindControl returns null; and this is because the control is not found. The whole idea of using FindControl is...
16 Jan 2012 by Prerak Patel
As Om Prakash said, you should put this code in Form_Load or Control_Load event.Just like,Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load cbo_StartYear.Items.Clear() 'CLEAR THE LIST FIRST Dim currentYear As Integer =...
22 Feb 2012 by Rahul Rajat Singh
I think the problem could be that the name of parameter is mismatching in code and stored procedure/query. and the filed that is giving the error is set as NOT NULL. double check spellings to make sure this is not the case. changing the table definition to accepts nulls could also do the...
22 Feb 2012 by ArjunBabu
Hi,This is my code. I have a 4 columns in a grid view, one of the column has a drop down list as the input control, 2 are text box controls and 1 is a label control (primary key). I get the error when the update action is clicked.Error: **No value given for one or more parameters.** ...
28 Feb 2012 by Rajjjjjjj
Hi all, I am working with gridview control in my form. I placed two dropdowns in two fields of gridview.Now i want to fill the second dropdown(inside gridviw collumn) based on the selection of the item in the first dropdown.I am unable to use If condition in the...
6 Apr 2012 by Reza Ahmadi
Hi,If you provide the Date part before binding, I mean in your Query, then binding code is very simple:
22 Apr 2012 by Mohamed Mitwalli
Hi , This will Give you ideaprotected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString)) { ...
15 May 2012 by snamyna
Hye..I have a dropdownlist which contains a customer record. I am facing a problem where although user select any item in the dropdownlist, the selectedvalue retrieved is the last item in the dropdown. Here is my piece of code to view the data in the dropdownlist.Dim sqlCust As...
20 Jul 2012 by Christian Graus
jQuery can't parse this to know that extrapetid[i] needs to be evaluated. Instead, add an index to the name for each control, like control1, control2, then use extrapetid[i] to access the object, and get it's unique id and pass that to jquery as normal. Having lots of controls with the same id...
24 Jul 2012 by _Amy
Hi,Use this://Dropdownlist selected value changed event. This can be done on button click event also.protected void DropDownList1_SelectIndexChanged(object sender, EventArgs e) { gvSorting.Sort(DropDownList1.SelectedValue, SortDirection.Ascending); ...
1 Aug 2012 by virang_21
Try something on your own first ... To start with check AJAX Control toolkit cascadingDropDown examplehttp://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx[^]
10 Aug 2012 by virang_21
On your dropdownlist's selectedIndexChanged event handler you can redirect to the page. Response.Redirect("Details.aspx?selected="+ddlId.SelectedItem.Value);You need to set AutoPostBack = true for your drop down list.
16 Aug 2012 by AmitGajjar
Hi,You can add your custom control in your page. That custom control should have features like,1) Paging for 10/20 records a page.2) page should be navigate through Next/Previous/First/Last/Goto.3) You need Searching in your custom Combobox.Here[^] some basic idea about Custom...
4 Oct 2012 by tanweer
hi, Offcourse --select-- is not a proper filter value and it should give error you have to put a check before calling the DB operations protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if...
14 Oct 2012 by OriginalGriff
The simple solution is: Don't do it.Think of it from your user's point of view: You try and find the one item you are looking for in a drop down of 400,000 items.If it simple? Quick? Easy?Provide a popup, or a filter, or something to make their lives easier.What you are proposing...
16 Oct 2012 by Milan Mathew
I have asp.net page with dynamic dropdown controls and I need only the selectedIndexchanged event to fire only for the user selection.At present selectedIndexchanged event is firing for each programatically selection changes.Can some one suggest how to check/fire the selectedIndexchanged...
16 Oct 2012 by Milan Mathew
The Solution provided by Marcus Kramer is working fine."Do something similar to this on the client-side with javascript where you effectively intercept the selectedindexchanged event for the dropdownlist and decide on the client side whether or not to let the postback occur. That is if you can...
29 Oct 2012 by Sergey Alexandrovich Kryukov
Popup error? You certainly want to scare off your users. Do yourself a favor: no pop-ups. Better review your UI. If some value should not be selected by the user, it should not appear in the drop-down list. It will take some effort though, but the reputation of a developer who does not show...
18 Mar 2013 by Sheikh Muhammad Haris
Try to bind dropdown with Value property, where editColDR would be value of your dropdown.and then use this javascript$('#tbl_ddlcolumnname').val(editColDR)
14 Aug 2013 by basavrajmswami
Hi,You can checkout below code insted of database connection i created my own collection datasource.// School entity which will define structure of entity public class Schools { public int OfficeID { get; set; } public String OfficeName {...
15 Aug 2013 by Member 9549287
the loop doesn't do any actual sorting. a simple way to go by sorting lists of objects would be: ......{sortedlist} = {unsortedlist}.OrderBy(dc => dc.{columnOrattributevalueyouwanttosortby});//or you could use the same unsortedlist instead of creating a new...
16 Aug 2013 by timJosh
Declared outside:static List offices = new List { };Then added this:public class Schools { public int OfficeID { get; set; } public String Description { get; set; } }And finally:dtOffice = blSchoolT.loadSchoolAll(); foreach...
15 Oct 2013 by Ankur\m/
Based on the discussion with the OP,1st DropDownList's AutoPostBack[^] property was not set to true. That is why nothing was happening on changing it. Setting it to true solved the issue.
25 Nov 2013 by Sergey Alexandrovich Kryukov
Why would you ignore my answer to your previous question? It can cost you too much, because this is about security. Not only this is not concatenation (which is only a good thing), but making queries this way is absolutely vulnerable to SQL injection:correcting concatenation query. C# and...
8 Mar 2014 by Sergey Alexandrovich Kryukov
No doubt it is possible. After all, menu is multi-level. What you need could be some combination of menu and drop-down control. I never saw such control, but, after all, http://www.ajaxtoolkit.net is open-source, so you can take the source and see how it is implemented and create your own...
22 Dec 2014 by PIEBALDconsult
You should have a translation table for referential integrity, you would then query that table, not the employee table.EmpTypeID Name1 Permanent2 Temporary3 SeasonalEmployeeID EmpType Name ...1 1 Bob2 1 Joe3 2 Bill
3 Apr 2015 by Peter Leow
Put the select code blocks inside the form, so that it can be submitted. PHP Forms[^]
23 Jun 2015 by Philippe Mori
Forget that. It make no sense to mimic old behavior on new browser. How other browser like Edge, Safari, Firefox, Chrome works? I don't thing that those details are defined and if so, then the new behavior would surely be the right one.By the way, the old IE way is a bad design. Why...
23 Sep 2016 by David_Wimbley
Unless you are forcing yourself to use plain javascript I would encourage you to look at jQuery. Also, I don't know what "I am getting the values and it displys in dropdown, but its not displaying in source code and not getting on form submit." means so I'll just ignore this part and give...
15 Dec 2016 by Philippe Mori
You should essentially never do something that make a standard control behave in an unexpected way.If you don't want to show the list, then why are you using a combo box to start with?The simple approach is to leave the list empty. It is not the best UI both in many cases one might might...
4 Aug 2020 by Member 11396175
Good morning I think my question is very simple for your experience one combobox with specific path give me the folders that have in it I want when i select one folder from combobox the files in the folder placed in the list box. What I have...
22 Mar 2010 by am.net
Hi to all, i need to create drop-down list in asp.net with items, which display all items but some of them disable for select.e.g public void fillDrp() { drp1.Items.Clear(); drp1.Items.Add(new ListItem("a", "1", true)); drp1.Items.Add(new ListItem("b", "2",...
31 May 2010 by Luke.Price
I have loaded a xml into my project and used xmltransform class to apply the Xslt so that it would sort the document by a particular column (while also using Xpath). I need to be able to change the sorting on the page to different columns by changing a Dropdownlist.I have tried various...
11 Jun 2010 by Christian Graus
Have you read the error ? Did you try doing what it says to do ?
11 Jun 2010 by sushilbondre
i tried it .... but as a newbie to asp.net..unable to solve it properly..please help...
23 Aug 2010 by Johan Boekhoven
Hi,I would like to know if it's possible to make an entry in the startmenu, near "my computer" where it shows my company name and then a dynamic list of important folders.start menu > myMenu > myDynamic entry 1 > myDynamic entry 2I'm using Winforms and would like...
23 Aug 2010 by Christian Graus
If your code is running as part of windows, you'd need to look into shell extensions, written in C++, I expect, to try to do it. I doubt, however, that you can add items there.
25 Oct 2010 by call to .net
Hi,I'm trying to make a order form where once the user selects an item from the drop down list, the label will automatically be populated with the user's selection.suppose user select item from drop down then label populate rate for that itemgive me a sample example..Thanks
25 Oct 2010 by Mohd Wasif
Ok for that u will have to write code on dropdown selected index changing andmake its autopostback property true;and write code as SqlCommand cmd = new SqlCommand("select * from tableme where item=@item ", con); con.Open(); cmd.Parameters.AddWithValue("@item ",...
22 Nov 2010 by rpriyank007
I have a table EMP_TAB with columns as NAME, ADDRESS, CITY, PHONE.I want something like this:I have bound a gridview with the datasource of above table, EMP_TABWhen I click on EDIT in gridview than instead of a textbox, I want a dropdownlist to be displayed for changing the CITY.The...
22 Nov 2010 by Sunasara Imdadhusen
HiYou should use Refer following link:GridView Examples for ASP.NET 2.0: Editing the Underlying Data in a GridView[^]Please do let me know, if you have any...
7 Dec 2010 by demouser743
I declared my template as follows ' DataTextField="year" DataValueField="year" /> I need to bind...
15 Dec 2010 by Toniyo Jackson
Add DataTextFormatString="{0:hh:mm tt}" in DropDownList,Try this,
15 Dec 2010 by John_mdk
Hi,Sample add custom DateTime Formating like asString.Format("{0:t}", datetime); Output "4:05 PM" .orString.Format("{0:T}", datetime); output "4:05:07 PM".follow this linkDateTime Formating
18 Jan 2011 by srinivasarao.y
Please. Can any one suggest to me How to resolve dropdownlist itemlist problem in ie8[^] with ASP.Net.[edit]1) You don't need to underline everything: it just looks messy, and nothing is highlighted. Keep emphasis for items that need to be emphasised.2) Urgency removed - all you will...
18 Jan 2011 by priyapavithra
http://www.w3schools.com/aspnet/showasp.asp?filename=demo_dropdownlist[^]
22 Jan 2011 by Eddie Niebruegge
I would like to set the DropDownStyle to DropDown in a ComboBox that is in a DataGridView control. I would like to do this by setting this property at design time; however, it isn't an option I can pick. Doing it when the form loads would be fine, but I don't know how to do it (VB.net,...
24 May 2019 by anthasaurus
8 Feb 2011 by Manas Bhardwaj
You should rather capture SelectedIndexChanging [^]or SelectedIndexChanged [^]event.
5 May 2011 by day_hard
the key was PreRender event like:protected void DropDownList2_PreRender(object sender, EventArgs e){ Label1.Text = DropDownList2.SelectedValue.ToString(); }
13 May 2011 by ZeeroC00l
Follow the below steps :* Extract the Information you want to bind the DropDowlList with, by making use of SqlConnection SqlDataAdapter and DataSet.* Use the following steps to bing the Data to the DropDownList DropDownList1.DataSource = dataSetName ...
13 May 2011 by anvas kuttan
hi, put an extra field in database as arrangeOrder and when you fetch data write to get orderBy arrangeOrder
10 Jun 2011 by Morl99
Please post code in a code block, it is virtually unreadable like this! You can do that by clicking the code block link at the top of the editor or by surrounding the code with and .If you just want to turn of the error... disable EventValidation (just like the error message...
10 Jun 2011 by Cathryn Crane
I tried that just to see if it would stop the error which it did but then it wasn't populating the dropdown either. I don't really want to disable validation.
10 Jun 2011 by Cathryn Crane
if (_this._xmlHttpRequest.readyState === 4 ) { try { if (typeof(_this._xmlHttpRequest.status) === "undefined") { return; } } catch(ex) { return; } ...
12 Jun 2011 by RossIV
Hello!I have a basic form setup in an html file. What I want to do is if a user selects a specific option in a dropdown box, then display an additional field on the page. Is this possible?Thanks!Ross
27 Jun 2011 by Prerak Patel
Dim countFrom() as String = DropDown1.Text.Split("-")Dim countTo() as String = DropDown2.Text.Split("-")Dim count as Integer = 0If Val(countFrom(1))>Val(countTo(1)) OrElse (Val(countFrom(1))=Val(countTo(1)) And Val(countFrom(0))>Val(countTo(0))) Then Throw New Exception("Error:...
4 Jul 2011 by Kuber Singh Manral.
public int returnTotWeeks(string s1, string s2) { try { string[] str1 = s1.Split('-'); string[] str2 = s2.Split('-'); int d1 = (Convert.ToInt32(str2[1]) - Convert.ToInt32(str1[1])) * 52; return d1 + (Convert.ToInt32(str2[0]) - Convert.ToInt32(str1[0])) +...
3 Jul 2011 by gani7787
Hi,I have two dropdown list. Each one contain start week and End week Details.Start Week : 1-2006(1st Week,year 2006) to 52-2020 (52 week,2020 Year)End Week : 1-2006 to 52-2020if i select startweek "1-2006" (1st week,2006 year) and EndWeek "41-2007" (41st week,2007 Year) then i...
20 Jul 2011 by itwasbydesign
Hello guys,Im having a problem in my code, i want to change the text of my drop-down list after i select and click a button, i want to select the default text of my drop-down list which is "Select" after clicking a button,For example i choose "PCS" in my list after i click the button the...
20 Jul 2011 by walterhevedeich
Try using this Javascript functionfunction Request(){ document.getElementById('unit').value= 'Select';}
20 Jul 2011 by Raju Prajapati
Plz try thisfunction Request(){ document.getElementsByName('unit').value = "";}
3 Aug 2011 by gani7787
Hi,I am using dropdown in my project. But, i want to apply the style and different color in my dropdown.can you pls. tell me the css for dropdown controls....?
9 Aug 2011 by patelKhyati
i have several dropdown lists in my asp.net c# project.i have set default value say "choose one" in drop down list and aslo set a validator for that dropdownlist.my problem is on buttonclick event my validator does not fire for the dropdownl list and also the default value "choose one"...
21 Aug 2011 by murtaza dhari
A generic dropdown control using LINQ to SQL and Entities using Reflection
25 Aug 2011 by Rajjjjjjj
I am working on asp.net i have created a webform. I placed 2 dropdownlist controls on it.1. In the first dropdownlist i saved 4 values(Country,State,District,Region) these four are the table names which present in my sqlserver2008 database.2. I want to display the first column...
25 Aug 2011 by #realJSOP
This gets the first column in the table (or null if there are no columns).DataColumn firstColumn = dataTable.Columns.FirstOrDefault();string name = "UNKNOWN";if (firstColumn != null){ name = firstColumn.ColumnName;}
25 Aug 2011 by prabhatkumartiwari
http://makeadvice.com/blog/?p=148[^]
19 Sep 2011 by qwerty 2
Hi all,I want to keep dropdown list column in the template field of a header and would like filter the data based on the options selected in the dropdown list of header column in the data grid..but not single row filtering,Its on the header where i need to filter the data with regard to a...
19 Sep 2011 by Tejas Vaishnav
Hello friend you need this changes1) set the autopostback property = true in header drop down2) generate a SelectedIndexChanged event of that drop down event3) in that event you have to write your code that will filter your data and that data will be reassign to your grid to re bind it...
9 Nov 2011 by Xaiver101
i want to populate a dropdown in object oriented manner. how can i do soo?
9 Nov 2011 by Wayne Gaylard
You just need to have a class that you want to use for selection, call it a Product class. Let this Product class have 4 Properties, ProductID, Description, Price and StockLevel. The first thing to do is gather a group of these into a List call this ProductList. Then in your form you...
27 Dec 2011 by melvintcs
function getCountry(x){var y=document.getElementById(x).value;document.getElementById('ctl00_ContentPlaceHolder1_lblCountry').innerHTML =y;}function...
27 Dec 2011 by amit28august
It may be the browser problem trydocument.getElementById('ctl00_ContentPlaceHolder1_lblCountry').innerHTML =y;document.getElementById('ctl00_ContentPlaceHolder1_lblCountry').value=y;document.getElementById('ctl00_ContentPlaceHolder1_lblCountry').text=y;it works fine for me and...
27 Dec 2011 by Ebnezer Oyenuga
Try using this code:cmd.Parameters.AddWithValue("@country", this.lblcountry.Text);to replace:cmd.Parameters.Add("country", SqlDbType.VarChar);cmd.Parameters["country"].Value = this.lblCountry.Text;