.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

how to populate a dropdown box based on selectedvalue in another dropdown/combo box

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :ASP.Net


I am new to MVC.  Can anyone show me how to populate a dropdown list box based on selected value in another

dropdown list box?  Say, for example, the first dropdown is a list of car manufactures.  When a user selected a manufacture from that dropdown list, the second dropdown would list would automatically gets populated with all the car models for that manufacture. 

Any help is greatly appreciated.



View Complete Post

More Related Resource Links

populate dropdown based on attribute criteria

Trying to load a dropdown list with the 'name' attribute from the category node...must be missing something: The xml: <Settings>  <department name="Accounting">    <category name="Bank Information">    <category name="Form Information"></Settings>    The code I'm attempting: XmlDocument settingsdoc = new XmlDocument();                settingsdoc.Load(Server.MapPath("/XML/Settings.xml"));                XmlNodeList nodeList = doc.SelectNodes("Settings/department[name='Accounting']");                 foreach (XmlNode node in nodeList)                    CategoryDDL.Items.Add(new ListItem(node.SelectSingleNode("//department/category[name]").InnerText)); CategoryDDL.DataBind();   Any idea what looks wrong? Thanks!

how to hide/display controls in NewForm.aspx based on dropdown value in SharePoint list



I have 1 dropdown in my sharepoint list with other columns. If dropdown value equal to 'xyz' i need to display some other controls, otherwise these controls should be hidden.

I know we can achieve this with javascript. If any one can provide code or sample then it will be appreciated. or is there any other alternative methods to do this ........

Thanks & Regards, Neerubee

On New Item form, select item on choice dropdown based on query result.


I posted this on Experts Exchange awhile back with no answer, so here's hoping someone here has an idea :)

So I've mostly figured this problem out, but I need some help in getting over the hump... note that I'm using JavaScript to do this (SPServices) on SharePoint 07'.

I'm on the New Items page of a list. Based on a user's selection in a "Teacher" dropdown, I'm doing the following:

1.) Get the value of the Teacher field and several other fields (School and Visit Date)
2.) Run a CAML query based on those fields to find the last list item entered for that Teacher

So here's where I'm stuck...

I have 10 choice fields, all with choices 0, 4, 7, and 10. Depending on what they were set to in the last entered item (which I queried), I want to set the selected item on each of those dropdowns to equal that. So "Score 1" was set to "4" on the la

Populating dropdown based on checkbox value in Infopath

Hi I have created a form library with the following values ID  Document   Preference 1   A                Yes 2   B                No 3   C                Yes   I have a drop-down and a checkbox in an infopath form. This dropdown will by default display the ID numbers. When a user checks the checkbox, then the dropdown should display only the id's that has "Preference" value equal to "Yes". I am using Infopath 2010 How to do this...Any suggestions...

filter a dropdown based on a check box value

Hi I created a dropdown in the infopath that will lists all the ID's from a sharepoint list. Then I added a checkbox in the form. When a user selects/checks the check box, the dropdown list should display only the student ID's Sample list I used ID    category 1      student 2      master 3      student 4      student 5      master How to do this. Any ideas, I am new to infopath 2010.

Populating a dropdown box with contents based on the selection of another dropdown box

Hi All   I am a complete newcomer to ASP.NET.  However in the few weeks I have been playing with it I have got pretty far and  have mastered things like stored procedures, gridviews, formviews and templates.  I have come across a problem which I am struggling with and could do with some help!  The scenario is this:   I have a dropdown box which is populated from SQLDataSource1   I have a second dropdown box which is populated from SQLDataSource2, but i need the query feeding this to be dependent on what was selected in the first dropdown box.    I assumed it would simply be a case of modifying the select statement on SQLDataSource2 using the SelectedIndexChanged event on the first DropDownList to update the second SQL source, but I cannot work out for the life of me how to do it.  Pretty much all of the code I have is ASP.   Is there a way I can do this purely in ASP rather than using VB behind the scenes or do I need to use VB?  I am pretty comfortable with vb.net but one of the other issues I have is referencing an ASP object from VB... so for instance if I had a text box in ASP, how can I read or change the properties of this object from VB?   FYI I am using Visual Studio 2010 and SQL/Server   Any help much appreciated!!!   Sean   

dropdown list wont populate values from database


Hello everyone i need help. Ive been having this problem for almost  3 days now. dropdown list won't populate from database

Below is the code i am using:

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="PhotoAlbum.aspx.vb" Inherits="PhotoAlbum" %>

<asp:SqlDataSource ID="categoriesDataSource" runat="server"  
<%$ ConnectionStrings:ConnectionString %>"  
    SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] WHERE ([UserId] = @UserId) ORDER BY [Name]"> 
<asp:QueryStringParameter Name="UserId" QueryStringField="ID"/> 

Populate in dropdown list control


Hello need some help on this one.  I am using ASP.NET with C# and Oracle database. I am trying to return some values from my select statement to fill my dropdown list control. I am designing this in a 3 tier architecture.  Here is my codes.  I am getting an error which states "Object reference not set to an instance of an object." I am returning the field name "NAME" to be filled in my dropdown control.  What I am doing wrong?


List.cs file code

public static string _GetClientList()


string clients = string.Empty;int SessUserID =

populate day dropdown on month change

<script type="text/javascript" language="javascript">
function testDate(value)

// var sel = document.forms(0).DDAY;
var sel =document.getElementById('DDAY');

sel.options.length = 0;

var NoOfDays = DaysInMonth(value);

for(var i=1;i<=NoOfDays;i++)
//create new option
var option = new Option(i, "Value" + i);
sel.options(i) = option;


<select onchange="testDate(this.value)" id="MMONTH" style="display: none;
z-index: 101; left: 0px; width: 80px; position: absolute; top: 2px" runat="server">
<option selected="selected" value="01">JAN</option>
<option value="02">FEB</option>
<option value="03">MAR</option>
<option value="04">APR</option>
<option value="05">MAY</option>
<option value="06">JUN</option>
<option value="07">JUL</option>
<option value="08">AUG</option>
<option value="09">SEP</option>
<option value="10">OCT</option&g

Dropdown lists - showing items based on value


Hi, i have over 100 items all loaded in a dropdown list. They all are assigned a value between 1-10 which represent 10 categories.

When certain buttons are clicked, i want the dropdown list to display only items with a value "1" or "2", etc.

How can this be done?

Cannot get ForeignKey to populate Dropdown


I am using a DynamicData - Entity project.  I have added a DynamicDataManager with AutoForeignKeys = true and also added a EntityDataSource with an include to the associated table.

<asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" >


<asp:DataControlReference ControlID="gvContact" />



<asp:EntityDataSource ID="EDS1" runat="server"



Include="Ref_Values, Ref_States">



The contacts table has many to one relationship with the Ref_Values and Ref_States table were it shoud retrieve a "text" value for the job title and state.

When the page is ran the gridview returns the integer value that is in the DonorContacts table not the foreign key value.

I have ensured that the relationship exist and that all tables have a primary key.  Also if I set the scaffold to true in the global.asax file and view the DonorContacts table the columns in question display the expected data, not the int.

I can get the correct value by using

Infopath generate URL based off of a selection of a dropdown.




Wondering if anyone had managed this or got any suggestions?

I have a list called terms and conditions, basically has title, and terms meta data.

I want to allow the user in the form to select which t&c are required for the specific request and then on save change it so that the t&c link to the dispform is shown.


Now is this something I will have to do purerly in code behind or can this be done with some fancy rules on the form?

exception error in customise dropdown combo


i create a user control of dropdown combo, it contains one textbox, datagridview and button.  when i add this dropdown combo (compile to DLL)  to another project, everything running fine, but problem is when i first load the form and try to keyin something in textbox, it comes out error 'object not set to an instance object' ...this error only come out when first load form, if i didn't keyin anything in the textbox but i click the dropdown and select the value, that can work, and if i delete the textbox value and re-keyin , its also ok,  its's just that when i close the form and then load the first time and keyin text, error comes out.

i suspect it is the textbox_textchanged event problem, because when i delete off the code here, its ok, but i can't do that cos i need to do the dataview rowfilter.  below is the sourcecode:

in the usercontrolcombo.designer.cs :

        private System.Windows.Forms.TextBox textBox1;

        public string txtBox
            get { return textBox1.Text; }
            set { textBox1.Text = value; }


How To: Filter a link list dropdown field in a form based on Active/Inactive field in the linked li


I need to filter a dropdown field on a form that is linked to another list.  The linked list has a field active/inactive and I only want the active ones to show on the form.

populate dropdown with code



i have 2 dropdown fields the first drop dropdown ownly holds 2 items : "technical questions","broken stuff".

i have made 2 data connection with the right lists.

the second drop down i want to populate, depending on the selected value.


i was thinking, i have already the data connections when i go to the code on the change event.

i can work with this data connection and populate the dropdown.

but i'm dooing something worng can anybody give some suggestions?



Filtering repeating section values based on selecting a value from dropdown


I have a repeating section in InfoPath 2010 which has questions associated to certain levels. The questions with associated levels are coming from Sharepoint 2010 list.

I also have a dropdown  where user can select which  level question they want to see.

I have tried few things here.

(1)Written code in c# on change of this dropdown to populate  the questions in the repeating section only if the level is what the user has selected.

It works perfectly fine on the client side but when I publish it as a form template onto SharePoint 2010 all the questions show up without any filtering.

appreciate any insights.

(2)I have also tried using conditional formatting, adding rules to hide the control(repeating section) if the questions level is no equal to the level selected in drop down. This also works gr8 on client side but not when published to Share point as browser enabled form template.


Can anyone tell me why this might be happening?


Dropdown list in ASP.NET - How to get value selected

am sure this must be very simple, but unforunately I can't figure it out.
I have the following code which populates the dropdown lists from the database. This works fine. Now, when the user selects a particular employee name from the list, I want to get the Employee Id of the selected employee. i.e. I need to get the "Eid" value. I can do this if the EId is loaded in the dropdown list, but in this case only the employee name is displayed. Please let me know howI can get the Eid value even though it is not loaded in the dropdown list.
I would really appreciate your help
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend