DropDownList selected value determines value of second DropDownList

I have a quick question that I'm sure has been addressed before, but I can't seem to find a solution.

I have two drop down list fields: startTime and endTime coded as such:
<asp:DropDownList id="startTime" runat="server">
<asp:ListItem Value="00:00">12:00 A.M.</asp:ListItem>
<asp:ListItem Value="00:30">12:30 A.M.</asp:ListItem>
<asp:ListItem Value="01:00">1:00 A.M.</asp:ListItem>
<asp:ListItem Value="01:30">1:30 A.M.</asp:ListItem>
<asp:ListItem Value="02:00">2:00 A.M.</asp:ListItem>
<asp:ListItem Value="02:30">2:30 A.M.</asp:ListItem>
<asp:ListItem Value="03:00">3:00 A.M.</asp:ListItem>
<asp:ListItem Value="03:30">3:30 A.M.</asp:ListItem>
<asp:ListItem Value="04:00">4:00 A.M.</asp:ListItem>
<asp:ListItem Value="04:30">4:30 A.M.</asp:ListItem>
<asp:ListItem Value="05:00">5:00 A.M.</asp:ListItem>
<asp:ListItem Value="05:30">5:30 A.M.</asp:ListItem>
<asp:ListItem Value="06:00">6:00 A.M.</asp:ListItem>
<asp:ListItem Value="06:30">6:30 A.M.</asp:ListItem>
<asp:ListItem Value="07:00">7:00 A.M.</asp:ListItem>
<asp:ListItem Value="07:30">7:30 A.M.</asp:ListItem>
<asp:ListItem Value="08:00">8:00 A.M.</asp:ListItem>
<asp:ListItem Value="08:30">8:30 A.M.</asp:ListItem>
<asp:ListItem Value="09:00">9:00 A.M.</asp:ListItem>
<asp:ListItem Value="09:30">9:30 A.M.</asp:ListItem>
<asp:ListItem Value="10:00">10:00 A.M.</asp:ListItem>
<asp:ListItem Value="10:30">10:30 A.M.</asp:ListItem>
<asp:ListItem Value="11:00">11:00 A.M.</asp:ListItem>
<asp:ListItem Value="11:30">11:30 A.M.</asp:ListItem>
<asp:ListItem Value="12:00">12:00 P.M.</asp:ListItem>
<asp:ListItem Value="12:30">12:30 P.M.</asp:ListItem>
<asp:ListItem Value="13:00">1:00 P.M.</asp:ListItem>
<asp:ListItem Value="13:30">1:30 P.M.</asp:ListItem>
<asp:ListItem Value="14:00">2:00 P.M.</asp:ListItem>
<asp:ListItem Value="14:30">2:30 P.M.</asp:ListItem>
<asp:ListItem Value="15:00">3:00 P.M.</asp:ListItem>
<asp:ListItem Value="15:30">3:30 P.M.</asp:ListItem>
<asp:ListItem Value="16:00">4:00 P.M.</asp:ListItem>
<asp:ListItem Value="16:30">4:30 P.M.</asp:ListItem>
<asp:ListItem Value="17:00">5:00 P.M.</asp:ListItem>
<asp:ListItem Value="17:30">5:30 P.M.</asp:ListItem>
<asp:ListItem Value="18:00">6:00 P.M.</asp:ListItem>
<asp:ListItem Value="18:30">6:30 P.M.</asp:ListItem>
<asp:ListItem Value="19:00">7:00 P.M.</asp:ListItem>
<asp:ListItem Value="19:30">7:30 P.M.</asp:ListItem>
<asp:ListItem Value="20:00">8:00 P.M.</asp:ListItem>
<asp:ListItem Value="20:30">8:30 P.M.</asp:ListItem>
<asp:ListItem Value="21:00">9:00 P.M.</asp:ListItem>
<asp:ListItem Value="21:30">9:30 P.M.</asp:ListItem>
<asp:ListItem Value="22:00">10:00 P.M.</asp:ListItem>
<asp:ListItem Value="22:30">10:30 P.M.</asp:ListItem>
<asp:ListItem Value="23:00">11:00 P.M.</asp:ListItem>
<asp:ListItem Value="23:30">11:30 P.M.</asp:ListItem>
</asp:DropDownList>
The same goes for endTime. What I would like to happen is once a user selects a time from startTime -let's say 4:30 P.M.- then the value of endTime would only display the list from 5:00 P.M. until the end. How can I go about accomplishing this.
I'm switching between Visual Studio and Web Matrix for development. Be gentle, I'm a PHP programmer learning ASP.NET for use in my company.
Thanks in advance to any help given.
0
rreister
10/7/2004 4:06:32 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

3 Replies
1370 Views

Similar Articles

[PageSpeed] 8

Oh - I'm coding in VB.NET.  Thought that may be important.
0
rreister
10/7/2004 4:14:57 PM
Basically you'd copy those ListItems,  from startTime DDL , whose index (ListItem's index in Items collection) is higher than the currently selected index in startTime DDL (SelectedIndex property),to the endTime DDL.
Thanks,

Teemu Keiski
Finland, EU
0
joteke
10/7/2004 4:17:48 PM

If you want to write a client-side solution, you can borrow from one of the scripts shown here.
If you want to save time and use an out-of-the-box solution with a ton of other features, consider using EasyListBox.
Cheers,

Peter Brunone
MS MVP, ASP.NET
Founder, EasyListBox.com
Do the impossible, and go home early.
0
peterbrunone
10/8/2004 3:27:42 AM
Reply:

Similar Artilces:

How Select one dropdownlist value using down arrows corresponding other dropdownlist value are select
I am using two dropdownlist box.One is used for country selection. other one is used for state selection.I am using dropdown selectedindexchanged event. when i click country dropdownlist corresponding state is selected in state dropdownlist box. How select the country in country dropdownlist using down arrow keys at the same time corresponding state is select in state dropdown list.R.Karthikeyan   kartmca: How select the country in country dropdownlist using down arrow keys at the same time corresponding state is select in state dropdown list.Generally, we don't implmenet...

Dropdownlist selected value passes first value in list no matter what value is selected. why ?
 HI . I have a dropdownlist. Databinds ok but when I must pass a value as a Selected value it always passes the first value in the list even if I select another value. I tried to set the ddl to enableviewstate false but it doesn't change anything. Any ideas ? Code below, thanksLoading the ddl:       productCategories = CatalogAdmin.Admin_Product_Categories_NotIn(productId);        for (int i = 0; i < productCategories.Rows.Count; i++)        {       &...

How to take selected value of dropdownlist in web method using cascading dropdownlist
Hi All,I am using C# asp.net 2.0 and ajax1.0.I am trying to fill dropdownlist using ajax cascading toolkit but I am not able to populate the dropdownlist.  My question is how do I take input value of parent dropdownlist in web service the fill the data that is in my senario I have subprod parent (fill on page load) and then Prod fill on subprod selection.  The web service method I used is  public CascadingDropDownNameValue[] GetProd(string knownCategoryValues, string category) { StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(known...

Two dropdownlists: first dropdownlist updates second via autopostback: Selecteditem.value always=1 for second dropdownlist
Hi All  This involves a form with 2 dropdown lists and other fields for user to fill.  dropdownlist 1 say countries of the world  dropdownlist 2 is cities in all the countries in the world when dropdownlist 1 is used to select a country, dropdownlist 2 is reloaded via autopostback event in list1 to show only cities in the selected country in list1, user can then select a city from list 2 and it would always match correct country. so far so good Problem: When I try to save the form to database, dropdownlist 1 gives me the correct value, but dropdownlist 2 always gives me...

VB.NET
I have a DataGrid (see code at end of my question) with several dropdownlist controls within TemplateColumns for Editing.  For the first 2 ddls in my grid, ddlMedType and ddlMedicationName, I would like to populate ddlMedicationName based on the selecteditem of ddlMedType, but I don't know how to reference this. Thank you for saving me from confusion!!!! Here is my DataGrid code: NOTE: I've bolded the 2 controls that I need help with -- the rest you can really ignore!! ================== <asp:datagrid id="dgMeds" runat="server" OnEditCommand="dgMeds_EditRow" OnUpdateComm...

dropdownlist's selected index value is not printing the selected value
Here iS my code .Aspx Page <asp:DropDownList ID="ddlkeyword" runat="server" Width="204px" DataTextField="Form" DataValueField="Form" OnSelectedIndexChanged="ddlkeyword_SelectedIndexChanged" >   </asp:DropDownList> <asp:Button ID="Button1" runat="server" Text="Submit" Width="110px" OnClick="Button1_Click" /> my aspx.cs protected void Page_Load(object sender, EventArgs e) { fillddlkeyword(); }protected void Page_Init(object sender, EventArgs e) { ...

Form: Focus on selected values in dropdownlists, Refresh after selection and hidding formfields based on selection.
Hello again,I have a form with several dropdown lists. Depending on the selected value in the dropdown lists other fields become available in that same form. It is working in classic ASP in combination of JavaScript. I want to migrate it to ASP.NET. I have posted a part of the form at the end of this post.My questions:1. I use <option <%If iFood="0" then%>selected<%End If%> value="0">No value selected</OPTION> to select the selected item when the form is reloaded after the selecting. I know that this also works in ASP.NET, but isn't there a typical ASP....

Handling DBNull Values in DropDownList Selected Value
I have a dropdown list inside a formview that is used to update a business opportunities table. Each opportunity may or may not have a salesperson assigned. On the update page I want to set the current value in the database as the selected value in the dropdown list. But if there is no salesperson assigned i need to handle the dbnull value and not try to set the selected value. Can someone give me some pointers? Should i handle this in the Formview_databinding event or in the Datasource for the opportunity Databinding event? How do i get at the cell of the datasource that i need to test for ...

Setting a label value to a dropdownlist selected value
I am trying to set the value of a label to the selected value from a hidden dropdown list. This code is not working and the label value remians at its default. Any ideas? Thanks very much. Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Dim mylabel As Label Dim myddl As DropDownList If (DetailsView1.CurrentMode = DetailsViewMode.ReadOnly) Then mylabel = DetailsView1.FindControl("Label1") myddl = DetailsView1.FindControl("DropDownListViewOffice") mylabel.Text = myddl.SelectedValue.ToString End If I have now put this code in the Page_Load su...

DropDownList value selected base on database value?
Hi, is there anyway how I can allow my dropdownlist (on pageload event) to select the value base on the value found in the database, in addition I also want the dropdownlist to contain other values too however the selectedValue must be the one found in the database. Sorry if it sounds confusing. I'm using VB.NET 2003 with ASP.NET Thanks. Hi,Whatever you want to get selected for your dropdown use following code.if(dropdownid.items.findbyvalue("value") != null){    dropdownid.items.selecteditem = false;    dropdownid.items.findbyvalue("value").selected = t...

Text value not changing when new value on DropDownList selected
Hi, I am looking for assistance on how to correctly post events when a new item is selected on a drop down list. My drop down list has autopostback enabled and a sub routine associated with SelectedIndexChanged. This routine is activated when another entry in the drop down list is selected, however, the value is not changed and the drop down list returns to the originally selected value. For example, if I have 2 values in my drop down list, 0 and 1, and 0 is the currently selected value. Selecting 1 will trigger the event but the drop down list will return to displaying 0 as the selected ...

populate second dropdownlist based on value of first dropdownlist
 I have two dropdownlists.one dropdownlist contains countries and second states.i get the the countries and states from back end sql server 2005.after getting countries and states i put them in cache in global.asax and bind it to two dropdownlistsnow what i have to do is. my two dropdown's contains ALL.when i select ALL in countries dropdown i need to get all statesbut when i select certain country i should get only states belong to that country.So i have to apply row filter.all the countries and states are in the same dataset.can some one tell me how to do that.i can show you my co...

Based on selected value from HTML.Dropdownlist, the values to be fetched
Hi,  I'm using Html.DropDownList.  When selection within this box changes, I need to retrieve the values from table based on the selected id(datavaluefield) of dropdownlist. Here my code ViewPost.cs viewpage <%=Html.DropDownList("CategoryID",ViewData["CategoryID"])%>  ---- based on selected value from the user the below table should fetch the value the db <table>        <tr>                   ...

dropdownlist
i have created a dropdown list that is populated from a sqlserver datasource. i have a separate sql command which uses the dropdownlist.selected value as a parameter and returns the command value to a label.  it mostly works fine but with one problem. when the page loads, the label value is null, because it doesn't seem to treat the dropdownlist default value as a selected value. when i use the dropdownlist to select a value, this is fine and the label begins to display the expected value. is there anyway I can make the default value when the page is loaded act like a manual...

Web resources about - DropDownList selected value determines value of second DropDownList - asp.net.web-forms

Tag Synonyms - Stack Overflow
Q&A for professional and enthusiast programmers

Accidental entities - what about the UI?
This post is a follow-up to my previous blog post " Accidental entities - you don't need that identity ". In that post, we followed a consultant ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Air Astana - Join Now
Thank you for considering membership of Nomad Club – Kazakhstan’s first Frequent Flyer Program. You could soon be on your way to earning free ...

Languages -> C# Articles, Tutorials, Examples: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Blog - Avisra
Avisra Web Development Home Blog Services Contact The Blog Latest Module Builder: How can we make it better? Sitefinity by Chris on July 2, 2013 ...

Online Booking Tool Support
This Online Booking Tool Support page might help you as you navigate through the process of booking travel through your OBT provided by CWT. ...

@Html and beyond
... ); } return string .Format( “{0}{1}” , me.Member.Name, id); } The Html building methods are quite simple. Building a dropdownlist for a ...

Top Ranked Articles
Top Ranked Articles - Free source code and tutorials for Software developers and Architects.; Updated: 23 Feb 2013

Unit Testing DateTime.Now Without Isolation
public virtual void SeedWithYearsSince(DropDownList list, int year){ for (int index = year; index

Resources last updated: 12/28/2015 5:25:37 AM