Dropdown list bound to another dropdown list

I have two dropdown lists on my page. The first contains a list of names and the second contains a list of hardware devices.

My problem is: When i choose a name from the first dropdown i need the second to become populated with their related devices. This works fine, however if i then change the name in the first dropdown list, it adds another set of devices to the devices dropdown list.

The way i want it to work is to refresh the devices dropdown when the name is changed. So that only that persons related devices show up (in the second dropdown)

 Any help would be much appreciated.

John

0
StefanHanotin
2/3/2009 11:44:36 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

8 Replies
1119 Views

Similar Articles

[PageSpeed] 22

 Hi,

    Follow this link,n ull find your solution.

    http://forums.asp.net/t/1376635.aspx

 

Plz Mark  as Answer if it helped you
 


Uthappa T.P
C# .Net
Visual Studio 2008
0
vinayuthappa
2/3/2009 11:52:07 AM

Hi Stefan,

            Just add the line before u assign the data source to the second dropdown list.

                       dropDownList2.Items.Clear();

Hope this helps U!!!


Regards,
Srinivas Ramanujan

Words offer the means to meaning, and for those who will listen, the enunciation of truth !!!!!
0
aresssrinivas
2/3/2009 11:53:24 AM

first clear the previous items of the 2nd dropdownlist

dropdownlist2.items.clear()

now populate the 2nd dropdownlist


Diseirra
Mark it as an answer, if it helped you anyhow...
0
diseirra
2/3/2009 11:53:51 AM

either clear the items collection (ddl.Items.Clear()) before you add the list of hardware devices of the newly selected user or directly bind the list using ddl.DataSource and ddl.DataBind() so that it is refreshed and not added.

0
BigjimFRG
2/3/2009 11:56:04 AM

 Hi,StefanHanotin

Create two method to populate hardware device.

one is for the Parent dropdownlist(on which selection you want to populate another dropdownlist.)  and anothere for Second dropdownlist.

in second method you put the where condition.After that you pass the selected value of parent Dropdownlist in second method and fill second method on the selectedindex changed of the parent dropdownlist.

 

 


Code Review Service || Join now: CodeASP.NET Community

Please mark the most helpful reply/replies as “Answer”.
0
vijjendra
2/3/2009 12:14:20 PM

Hi  StefanHanotin ,

You must clear the items in your Devices dropdownlist in the SelectedIndexChanged event of first dropdownlist. So each time you select an item in first dropdownlist, the second dropdownlist will contain required non-repeated items. Here goes the simple illustration:

<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"></asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server"></asp:DropDownList>
1    //selected index changed event of first dropdownlist
2        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
3        {
4            DropDownList2.Items.Clear();
5            //*** Your databinding logic goes here
6        }

Hope this helps. Please feel free to ask if there is any confusion. Thanks.


Lets always remember to mark the post that helps us as "Mark as Answer".
A .NET Programmer's Experiences
0
sangam100
2/3/2009 12:20:02 PM

Hi StefanHanotin ,

Happy to help you. Thank you.


Lets always remember to mark the post that helps us as "Mark as Answer".
A .NET Programmer's Experiences
0
sangam100
2/4/2009 4:54:42 AM

Hi I have a similar problem.... there is a datalist and in the footer there are two dropdownlist, when the 1st one is selected the 2nd one should be updated.  JUST in case I'm using asp.net 1.1 with sql 2000

<FOOTERTEMPLATE>
  <TR>
     <TD>
       <ASP:BUTTON commandname="addPage" id="butAdd" runat="server" text="Añadir"></ASP:BUTTON>
     </TD>
     <TH align="left">
         <asp:DropDownList ID="addCompany" Runat="server" datavalueField="id"
              DataTextField="nombre" AutoPostBack = "true"
              OnSelectedIndexChanged="fillOtherDrop" DataSource="<%# fillCompany() %>" >
         </asp:DropDownList>
     </TH>
     <TH>
        <asp:DropDownList ID="addClase" Runat="server"></asp:DropDownList>
     </TH>
     <TH align="left">
         <ASP:TEXTBOX id="addYear1" runat="server"></ASP:TEXTBOX>
     </TH>
     <TH align="left">
         <ASP:TEXTBOX id="addYear2" runat="server"></ASP:TEXTBOX>
     </TH>
  </TR>
</FOOTERTEMPLATE>

0
pcsan
4/21/2009 7:00:37 PM
Reply:

Similar Artilces:

one dropdown list affecting another dropdown list vb.net
I am desgining a website using VB.NET wherein the data items of one dropdown list depends on the selection of a data item in the previous dropdown list something similar to selection of country USA from 1st dropdown list...triggers 2nd dropdown with list of states in USA How can this be accomplished.... Any help will be appreciated... Thanks & Best Regards... hi boy,first I suggest turn on auto postback on first dropdownlist. In select index changes(first dropdownlist) - select value on second dropdownlist My blog is here.Please remember to 'Mark as Answer' i...

Filter dropdown list from another dropdown list
Help Please!!! I am trying to filter the data in a dropdown list from information chosen in another dropdown list. 1st table has modification types, 2nd table has modifications. When the user chooses the modification type needed, then only those modifications should appear in the 2nd list. mydata7 = New SqlDataAdapter("Select * from ModificationList ", myconnection) ds7 = New DataSet mydata7.Fill(ds7, "table") Dim dr7 As DataRow ddlModification.Items.Add("Please select Modification ...") ...

Populate a Dropdown List based on the value of another Dropdown List
 Hi ALL,    I have two Dropdown List.I need to Populate second Dropdown List based on the value of first Dropdown List.I am n't using Update Panel.Pls suggest me RegardsSri ASP.NET AJAX Cascading DropdownDarrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!   just populate second dropdown in SelectedIndexChanged event of the first dropdown. Muhammad ShoaibSoftware Engineer,Lahore, Pakistanwww.heartofpakistan.com (U/C)--------------------------------Mark it as ANSWER if it Helps U   Check out this link with co...

Filling a dropdown list, based on a selection from another dropdown list
This seemed like a simple venture, and may be, but with my limited asp.net knowledge, I am having a problem... Basically, I have a page that is gathering information. I want a user to be able to select a value from a dropdown list... On Auto postback I would like to make a second listbox visible and bind data to it based on the selection from the first. (While keeping the value of the first listbox available) Right now I am filling my dataset with the tables used in the page load event and setting my second listbox.visible to false. in the SelectedIndex_change event of the first...

Can I populate a Dropdown list in a GridView from another Dropdown list
Hi there, I have a Gridview control that contains 2 DDLs. The first one is populated on page load (from a Generic list in the code behind) and is working with no problems. I want to populate the 2nd DDL by making a selection in the first DDL which in turn would call a DB method and cause a postback. I've tried using the "OnSelectedIndexChanged" method for the DDL and the "FindControl" method for the 2nd DDL, but the GridView can't find it on Postback and throws an error. I've also tried using the "onSelectedIndexChanged" method for the GridView bu...

Populate dropdown list based on selected value in another dropdown list
I have a datagrid (grdCar) that contains two dropdown listboxes (ddlCarManf and ddlCar). When the user clicks the "Edit" link and places the grid into edit mode, they select a value in ddlCarManf. Based on the selected value in ddlCarManf, I need to then populate ddlCar with a list of cars for which the selected manufacturer makes (I'm using ddlCarManf.SelectedValue to query the database).  I bind my datagrid in the page_load event as: If Not Page.IsPostBack Then    BindGrid() End If Here is my control (ddlCarManf) as is appears within grdCar in ...

Selection in one dropdown list effecting the visibility of another dropdown list
I have two drop down lists. They are not databound. We'll called them dropdownlist1 and dropdownlist2.Basicly, I want people to choose an object in the first dropdownlist. Depending on their selection, it will make certain items in dropdownlist2 invisible.Currently my thought is to have something in the lines of the following (In the dropdownlist1 - SelectedIndexChanged - Postback being set to Auto)if dropdownlist1.text = "Such and such" then(this is where I would declare which options are available)However, I do not know the proper syntax of saying make the following item...

automatically generating content in a dropdown list based on the selection of another dropdown list
hi i currently have a "categories" dropdown list i'm using to help filter data in a datagrid (have it setup using data and table adapters). i've introduced another dropdown list (called subcategories) to filter the datagrid so it only displays records that fit in both the category and subcategories.it all works fine, but i'm wanting to set it so the subcategories dropdown list gets generated on the client-side depending on the category selected. does anybody have any quick tutorials or a quick explination on how i could do this? am i missin...

populate a dropdown list on the basis of other dropdown list
I need to populate a dropdown list on the basis of other dropdown list. Both dropdwon list are datasourced with SQL datasource. I tried the SQL datasource where query . but it will need a post back. I dont want my form to be postback. I guess this is what AJAX is for but i really dont know how to get this with AJAX in a simple and quick way..... or it is not simple and quick ????Mark as answer if anybody's post has helped you It can be simple and quick.  See this video:http://www.asp.net/learn/ajax-videos/video-77.aspx And also the tutorial on how to use the Cascading Dropdow...

Load Text box of one web form with selected list item of list box of another web form
one help please Problem is i have two web forms  1.  ForiegnkeyTest.aspx  2. foroginkeytable.aspx   step 1 1 ForiegnkeyTest.aspx one web form <head runat="server"><script language="javascript" type="text/javascript">   function popWin()   {         var confirmWin = null;      confirmWin = window.open('foroginkeytable.aspx','anycontent',   'width=455,height=435,status');   }  </script> &...

Hide dropdown list based on other dropdown list selection
Hi, i have an aspx page with a form. I want to hide dropdown list b depending on what is selected for dropdown list a. I need to do this client side Im new to this so any assistance would be appreciated. Thanks in advance   could you explai briefly about your requirements? you want to maske dropdownlist b as invisible if you select any item on dropdownlist a? or you want to make it invisible for a specific item?   Hi,     Change the visibility of dropdownlist as false on selected index change. Private Sub ddl_a_SelectedIndexChanged(ByVal sender As Syste...

How to combind two dropdown list values into one dropdown list?
Hi All, I refered some websites, they are combinding two dropdown list values into single, but i don't know .Net will support it or not? If any body knows it plz tell me how to achieve it?? EX: Go to Naukri.com and select Functional Area dropdown list there u can see main & sub category names in one dropdown list!!!   Thanks, Aswath.  hi just concatenate , or - for ex:Dropdownlist1.Datatextfield= maincategory & "," & Subcategory Regards,M.VenkatesanMy Blog : http://venkat-dotnetsamples.blogspot.comPlease remember to click “Mark as Answer” on the pos...

Using a selection from a dropdown list to fill in a second dropdown list.
Hi,  I am new to the web programming area and looking for some help.  I have a situation where, like i said in my subject trying to base the list in the ddl2, to be based on the selection from ddl1.  What do i all need to include to do this.  As of now, I have two seperate SQL data sources, with the first one I have it just selecting from our database.  For the second list, I have a second sql data source that does a selection of a different column from teh same database but in the where clause have a parameter that will equal the selection from teh first.. &n...

Drop down list in Form view returns error when value in bound field (data binding
I get the following error when I click edit to edit the details in the web form:'ddlUserRestrictionType' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value  I would like it to accept any value which currently exists in the database. Is this easily achievable? With what you've posted, all I can tell is that you are trying to set the SelectedValue of a ddl to a value that does not exist in the list.  It would be helpful if you can post some code and the expected values of this control.~ Timwww.bucketo...

Web resources about - Dropdown list bound to another dropdown list - asp.net.web-forms

How to convert unordered list into nicely styled <select> dropdown using jquery?
$('ul.selectdropdown').each(function(){ var select=$(document.createElement('select').insertBefore($(this).hide(); $('>li a', this).each(function(){ ...

Credit Suisse Reiterates On Enbridge Energy Partners, L.P. Following Alberta Dropdown
In a report published Thursday, Credit Suisse analyst John Edwards reiterated an Outperform rating on Enbridge Energy Partners, L.P. (NYSE: EEP), ...

Convert a Menu to a Dropdown for Small Screens
Create a menu that, on smaller screens, changes into a dropdown menu. A dropdown takes up much less screen real estate and can be easier to use. ...

Office-Add-in-Fabric-UI-Sample/Dropdown-demos.html at master · OfficeDev/Office-Add-in-Fabric-UI-Sample ...
Contribute to Office-Add-in-Fabric-UI-Sample development by creating an account on GitHub.

Google Adds Dropdown Menu to Search Results, Hides Cached Pages Inside
Google recently updated their search results format, again moving the link for cached page access somewhere else. Now it hides in a convenient ...

50+ Awesome jQuery Dropdown Menu Tutorials
When designing graphical user interfaces, many people prefer to use a dropdown menu as a GUI element. This allows the user to choose a value ...

Sign out command in dropdown
We can save some space in the menus by putting the Sign-out command in the dropdown menu. As we're building the menu, if I see a command called ...

Google toys with removing Instant Preview in Search, adds dropdown menu with Cached, Similar, Share options ...
Google has added a new drop-down menu to its search results page beside every URL with three options: Cached, Similar, and Share. At the same ...

Facebook Fan Page Changes You Haven’t Heard About
... fashion appears at the top center of the page if you scroll down to the cover image or any point lower. A box labeled highlights has a dropdown ...

Edit Companies - Eric Feng - CrunchBase Person Profile
If this person is an investor, please only submit companies for which he/she has a functional role (like Board, Advisor, etc). Click 'Past?' ...

Resources last updated: 11/29/2015 7:57:22 AM