Drop Down List Populated Depending Upon the value Selected in another Drop Down List


I have five drop down lists.Each One populated based on the value selected in the previious one.

I have used SqlDataSource for binding data to each drop down.And I need some initial value so I put "AppendDataBoundItems" as true.Functionality is ok.

The problem is,

I have selected one from first dropdown.then second drop down is populated.but now i want to select a different value from first dropdown.If i do so,To my second drop down list the values r being appended.not refreshed.I think this is because AppendDataBoundItems=true

Plz suggest me something.

Thanks in Advance. 

Im novice to .net and been exploring .net these days

8/28/2007 10:12:08 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 5


clear your second dropdown before binding.. so it will bind only new values only not appending to the prevouse one..

Best is Not the END point, but a starting point for Innovation
Remember to mark posts as the "Answer" to help future users.
8/28/2007 12:13:40 PM


But how. Is there any property to clear a drop down before data binding,I couldnt found such thing.

If so plz help me.

8/28/2007 12:54:19 PM

Do i need to do it manually.

Like On SelectIndexChanged or something,i have to clear and i have to add the default item(initial value).

Is there any other way.

I have searched but i couldnt find.


8/28/2007 1:21:59 PM

DropDownList1.Items.Clear(); will clear the items. You can add the inital item in the DataBound event of the drop down DropDownList1.Items.Insert(0, new ListItem("Select", "Select"));

Thank you,
John M. Perry
8/28/2007 1:25:36 PM


Thanks. i did it. But not on DataBound Event.On SelectIndexChanged for previous drop down. and i have "AppendDataBoundItems"=true. for adding static item in DropDownList.So i can have the default item every time.

It is like,

protected void CategoryDropDown_SelectedIndexChanged(object sender, EventArgs e)



new ListItem("Select Release Number", "0"));                     --DropDownList1


protected void ReleaseDropDown_SelectedIndexChanged(object sender, EventArgs e)


ApplicationDropDown.Items.Clear();                                                                                    --DropDownList2

new ListItem("Select Application", "0"));



I have 5 drop downs like this.

Thanks once again.

8/29/2007 5:04:05 AM

Similar Artilces:

Populate a second drop down list upon selection value of the first drop down list in a gridview
How to Populate a second drop down list upon selection value of the first drop down list in a gridview? DropDownList1 ******************* <asp:TemplateField HeaderText="SystemName" SortExpression="SystemName">                <EditItemTemplate>                    <asp:DropDownList ID="sysidddl" runat="server" DataSourceID="sysods1"    &nbs...

How to get the list of second drop-down-list based on value selected in the first drop-down-list
I have two drop-down-lists, the second one depends on the value chosen in the first drop-down-list.  In the first drop-down-list, I have AutoPostBack = "true" and OnSelectedIndexChanged = "SelectedIndexChanged" In the selectedIndexChanged method, I do the following: 1    protected void SelectedIndexChanged(object sender, EventArgs e)2        {3            if (IsPostBack)4            {5      &nbs...

How to populate one drop down list based on the item selected in another drop down list?
Hello Mate,                      I have two drop down lists. I have to populate one drop down list from Database  based on the selection of an item in another drop down list. And i dont want the page to be posted back while performing this operation.                      If you have an idea about my issue, Please let me know!.Much Obliged & Thanks a Lot,Myself Hi, you can craft ...

Populate 2nd drop-down list box based on selected values in 1st drop-down list box
Hi Group,I have two DDL boxes on my page.  DDL one has a list of values and a code.e.g code  ValueABC   123ABC   345FGH   123 DDL 2 should only show values for the code selected in  DDL1 e.g  if user selects record 1 with code ABCthen DDL2 should show ALL records with the linked field value of ABC.The tables are normalized.  For your info, the name of the field of the value I would like to check is called sublistcode.Using vb.net  TIA         Try this code: Note: Set appenddataboun...

Drop down list read its value from another drop down list
Hi, In Desktop that is so easy, either CBox.SelectedIndex = CBox_Master.SelectedIndex! but in ASP.Net i'm confused, here is the case Camps contain rooms, In rooms page, i have a drop down list contain the name of camps, its supposed that any room inserted or renderd in that page to belong to Camp in the drop down list, the selection is working good, now, i use a Form View to Insert new records in room table, in the insert template i place a drop down list for a user to chose from, by default its a textbox, and the camp_id is number, however i want shoe the camp name not number, so i dr...

FormView: Filter a drop-down list based on a selection in another drop-down list
Hi Everyone, I have a FormView and in it is a drop-down list for "Clients". Below it is another drop-down list: "Contact". The database is set-up so that each clinet has one or more contacts. So, when I change the selected client, I want the list of contact to update. Here's the code: '> " SelectCommand="SELECT [Client_ID], [Client_Name_Short] FROM [tbl_Clients] WHERE ([Is_Active] = @Is_Active) ORDER BY [Client_Name_Short]"> ...

Drop Down List in a Data List =- How can I select a specific item in Drop Down List
I have put a drop down list into a data list. It will have a list of cities in it related to the market I am writing this for. I need to have this select the city where a current customer is doing business so that if they move they can use this drop down to select the city they moved to in the market How do I set a default row in the dropdown? I now goes to row 0, probably the wrong one If you know what the default value is supposed to be, the easiest way to preset the dropdownlist control is to write code in the ItemDataBound event of the DataList using the FindControl method to get ...

Not getting Selected values in a drop down list (populated by ajax ) while Submiting
I have a problem while using ajax. I have two drop downs when i select a value in the first i populated the second based on that (using ajax) but when i submit my form i couldn't  get the selected value from the second drop down(which i populated using ajax can anyone provide any solution to this problem Hi Jereesh, Can you post your code here. Thanks! Regards,  Dennis van de Laarhttp://dennisv.net/Don't forget to mark the most helpful reply/replies as Answer. Hi,  this is the code i have used --my page class is : wfrmManageemployee --and in the page loa...

Insert a value in to a Drop Down List that has the list populate from SQL200
I am trying to learn .net 2.0. I have a Drop Down List which has it's values / items bound from a stored procedure on a SQL 2000 server.  Using the very simply 2.0 coding method to populate the Drop Down List is working perfectly.   I would like to add a value at the beginning of the drop down list which says "Select One".  <asp:DropDownList ID="ddl_SectionName" runat="server" DataSourceID="ddl_SqlDataSource"DataTextField="str_CategoryName" DataValueField="int_CategoryNumber" > </asp:DropDownLi...

Drop down list state or getting the right value from the list
 Just a little background hopefully someone can help me ive been at this for about 1 week now i cant seem to get it. Im using 1.1 i dynamically load a bunch of drop down lists on a page from a sql 2k database. When i load the page everything is fine. The issue is when i postback. I select an index in a drop down but it doesnt stay  im trying to redirect when the value is chosen but all it is doing is reloading the dropdown with all the data Ive tried adding a button to grab the value of whats in the drop down but i cant do that if every time the page reloads back to the server it r...

Cannot get a Selected Value From a drop down list
I'm trying to get a selected value from a drop down list to put into a database, I keep getting the following error. Line 100 seems to be causeing the problem. BC30456: 'SelectedValue' is not a member of 'System.Web.UI.WebControls.DropDownList'. Line 98: Dim dbParam_usr_stylesheet As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter Line 99: dbParam_usr_stylesheet.ParameterName = "@usr_stylesheet" Line 100: dbParam_usr_stylesheet.Value = ddl_style.SelectedValue Line 101: dbParam_usr_stylesheet.DbType =...

Getting Selected Value in Drop Down List
I have a datagrid that when you click on the editOnCommand Link, creates a drop down list inside the DG with values. There is an exteranl Datasource that gets the values for the DDL inside the DG. There is a table called tblAOParishContactInfo that contains the values that populate the DG. The table (tblAOParishContactInfo) also holds an ID that references a table called tblAOParishContactTypes. This table is that table that gets referenced to populate the DDL in the datagrid. What I want (or my boss wants) is when you click on the edit link, it populates the ddl like normal, but the value I...

cannot get selected value from drop down list
I am using ASP.NET with C# and Visual Web Developer Express...I have a drop down list which is populated using a datatable, but when I change the value in the drop down list, I cannot retrieve the ID of the newly selected value. My DDL is setup as follows:DropDownList_CompareDocs.DataSource = dTable_DocVersions;DropDownList_CompareDocs.DataTextField = "Doc_Description";DropDownList_CompareDocs.DataValueField = "VersionID";DropDownList_CompareDocs.DataBind();The DDL have the following data:VersionID    Doc_Description1      &nbs...

Cascading drop down lists: changing the primary list causes the secondary list to refresh BUT it retains the old selected value/item
I have two drop down lists. For the purposes of this example let's call them ddlState and ddlCity. ddlState is selected first, I may pick Texas.  Then the page refreshes and ddlCity has all the cities in Texas.  So I may pick the 5th one and it is Austin. Now I change my ddlState to California.  The ddlCity displays the first entry in the City list, HOWEVER, that entry is not selected.  The ddlCity.SelectedItem.ToString displays as Austin still. So the way I see it I have two options: 1. Insert a "Pick a City" programatiacally to the drop down list...

Web resources about - Drop Down List Populated Depending Upon the value Selected in another Drop Down List - asp.net.getting-started

List of populated places in the Tibet Autonomous Region - Wikipedia, the free encyclopedia
This article includes a list of references , related reading or external links , but its sources remain unclear because it lacks inline citations ...

How Will We Sustain a More Populated Planet? - Flickr - Photo Sharing!
An artist's view of the Landsat Data Continuity Mission spacecraft in orbit above the Gulf Coast of the U.S. Credit: NASA/GSFC/Landsat NASA image ...

Melbourne on track to be most populated city as people flock to Victoria: Australian Bureau of Statistics ...
Australians are flocking to live in Victoria in record numbers with data showing Melbourne is set to become Australia's biggest city by 2056. ...

Iraqi PM orders army to stop shelling populated areas held by militants
Iraq's prime minister said Saturday he has ordered the army to stop shelling populated areas held by militants in order to spare the lives of ...

2/3 of Apple's iOS App Store populated by 'zombie' apps, estimate finds
Most of the applications on Apple's iOS App Store are un-downloaded, unranked, and largely invisible software options.

The ‘Villages’, Florida ranked as the fastest growing and most heavily populated metro area in the United ...
... Census Bureau the ‘Villages’, a census-designated place in Sumter County, Florida, has ranked as the fastest growing and most heavily populated ...

"Thus did humans inadvertently create an ecological niche for a predator in one of the most densely populated ...
"In an exceedingly brief period, coyote, wolf and dog genes have been remixed into something new: a predator adapted to a landscape teeming with ...

NorCal Drought Forcing Rabid Skunks Into Populated Areas
Rabid skunks are on the rise and have been spotted in high numbers in Northern California. They are more aggressive and some have even gone after ...

Lava from Hawaii volcano moving toward populated area
Officials are not ordering an evacuation for residents on the Big Island, but are telling them to be prepared for it

China limits drone usage in populated areas
The Chinese government will soon launch new regulations that will ban drones being used to deliver goods to densely populated cities and towns. ...

Resources last updated: 12/15/2015 8:03:37 PM