Setting the datasource of one dropdown box based on the values selected in another

As the title says, how is this done.

I thought it would as simple as saying something like:

If dropdown1 SelectedValue = 1 Then

    dropdown2.datasource = 'what's the exact syntax here?

End if

Can someone let me now how this is done please?

 

TIA,

Mo
 

 

0
mojo99
8/20/2007 3:29:59 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

4 Replies
575 Views

Similar Articles

[PageSpeed] 31

 dropdown2.datasource = 'The list of data you want to bind.'

don't forget to put

dropdown2.databind();

to bind the dropdown to your new datasource
 

0
Bart
8/20/2007 3:37:57 PM

 Thanks very much for the prompt reply Bart. I've tried what you suggested and which works - sort of! I probably didn't explain myself very well the first time.

 

Anyway, I need to set both the text and the value of the second dropdown. For example, what I have in  mind is this:

0;Missing
1;Maternal age
3;OSCAR

'Missing', 'Maternal age' etc is what the user sees. What gets wriiten to the db are the values 0, 1 and 3. Is it possble to set both these values do you know?

Thanks again.
 


 

0
mojo99
8/20/2007 3:48:59 PM

 dropdown2.Items.clear();

dropdown2.items.add(new ListItem("Missing","0"));

dropdown2.items.add(new ListItem("Maternal Age","1"));

 dropdown2.items.add(new ListItem("OSCAR","3"));

 User sees text, but selected value will be the string value of your second parameter.

If you want it as integer, you need to convert it.

 

Greetz
 

0
Bart
8/20/2007 4:02:56 PM

Thanks very much. This is exactly what I need.


Mo 

0
mojo99
8/21/2007 8:06:10 AM
Reply:

Similar Artilces:

On selecting of radio button, set the value of one dropdown box = to another dropdown box
I have a simple vb.net form.  On it is a drop down box, a radio button list, and another drop down box.     First the user makes a selection in the drop down box, then if they select "yes" in the radio button list, I need the change the value of the 2nd drop down box to equal the value from the first drop down box.  I've tried the following, but it doesn't work.. thr...  any suggestions? my codebehind.. where Iam trying to set the selectedvalue of BillingAttorneyID = AttorneyIDProtected Sub rbBillingSplitYes_CheckedChanged(ByVal sender As...

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> &...

can i drag the selected value of dropdown list in one web part to another web part
hi, supose i am having time displaying in on webpart can i drag the value of time to another web part and and display the time is: and the value draged from the other webpart so i want to drag the value year and population into antoher web part and according to that the grap must appear i.e what  i exactly want is i must drag some value from one webpart to onother webpart and according to event some thing must happen in another web part   Hi, The problem has been replied in the following post: http://forums.asp.net/t/1141884.aspx But from the title you described, do ...

Select values from one table based upon values in another...
How do I:Select f1, f2, f3, from tb1 where f1=Select f1 from tb2 where f1='condition'?Rex WinnCode-frog System Architects, Inc.VS 2005 Professional, C#, C++ Well... You might try reading up on some standard sql syntax... There are a number of different ways... Select t.f1,t.f2,t.f3 From tb1 t INNER JOIN tb2 t2 ON t.f1 = t2.f1 Where t2.f1 = 'condition'   Select t.f1,t.f2,t.f3 From tb1 t Where t.f1 IN (    Select t2.f1    From tb2 t2    where t2.f1 = 'condition')   Select t.f1,t.f2,t.f3 From tb1 t Where exists (select t2....

How to set a dropdown value in a form based on a value read from a database?
We wish to populate a form based on information read from our database.One of the controls is a dropdown list. We first fill up the ddl from a table of about 60 values. Then we read a value from a different table that was saved data earlier to see which of the 60 values was picked. We wish to show the user that value in the dropdownlist when we display the form. How can we do this?For example, we fill the dropdown list with school course codes (French, German, Math, etc.) , then wish to read a different table in the database and select the dropdown item based on what we r...

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 ...

Passing Values from a Web Form to Another Web Form
Hello All! I am trying to pass values from one web form to another web form. I know that there are 3 ways of doing this: queryString, Server.Transfer and Session. I am using the Server.Transfer method. But I am not able to create, in my 2nd web form, an instance of my 1st web form. My 1st Web form is named CallTrack.aspx and my 2nd is named Export.aspx. What I mean is something like this: Public value as CallTrack. I can't create it in my 2nd web form because when the intellisense is displayed, there's no CallTrack in the options. Thanks!   How about using cross-...

hide only the dropdown value while selecting the another dropdown value
 hai  friend i am using two dropdown list if i select one dropdownlist the another dropdownlist value must be hidewhat can i do for this     Ramesh.Dhttp://rameshduraikannu.blogspot.com  u can do that using javascript..function Hide(){ var drop1 = document.getElementById('<%=dropdownlist1.ClientID%>')  var drop2 = document.getElementById('<%=dropdownlist2.ClientID%>')  if(...

cascading dropdown set it's value only once but not on subsequent postbacks,web service recieve the value but can't set in dropdown
i have a dropdown named uxcommunity which is a dropdown and contain text in format ##-####-#### . and 2 more dropdowns province and district where province filters district. i get the first 2 characters ##  for session("province") and #### for session("District") and i have button to do the postback. first when the form loads and i click the button it get the value and select appropraite items in to dropdown province and district. but when i change the province dropdown content and district dropdown content and click the button , session will take correct...

Selecting value in one field then causes value in another field to be selected.
I have a web form which contains a date field, the date is populated using a DatePicker which is Javascript based. The form also has a drop down box containing 3 values. What I want to do is when a date has been selected that this will cause the dropdown list value to change to dated which is one of its 3 values. i.e. when the date field is not blank then the value will be selected in the dropdown. What I also want to happen is when the date has been selected and the dropdown value is dated then the date field and the dropdown field will be set to read only.Anyone any ideas how to this usin...

synchronizing chunk of data of one web form for another web form
I'm making a web application. In one web form; i'm taking inputs from user. Now; there is some info given by user in this page which is needed for web form which is going to be displayed next. i want to display that info automatically on that web form so that user doesn't have to re-input that info in this next web form. Info from first page would be inserted into database when user clicks on the submit button. then that next web form would be displayed. and the chunk of info from previous page should be displayed there!!! how can i do this?? cany anybody help?? nobody can help me!! I...

using a value on one web form on another....
I have a web form of textboxes. When a user fills out the form and clicks a button, i want the form to go to another form, and I want one of the fields to carry over on the other form on page load... any suggestions??? have you tried using a querystring? are any of the fields needing to be saved/inserted into a database, before you go to the next page? David WierMCP/ASPInsiderASPNet101.com - where to look first!Please Vote for ASPNet101 - 'Best Community Resource'!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best H...

Changing the contents of one DropDown based on the value of another..
Hello, I have a DataGrid that will have two Template columns with DropDownlists. While in edit mode, user will select a value in DDL1. Then depending on what the user selected, a query to the DB will populate values in DDL2. While in edit mode, the user may continue to look a different values in DDL1 and DDL2 will have to be populated accrodingly. Any ideas?? Thanks -Steve Hi, Have a look at this article. DataGrid with Multiple DropDownLists Regards Ram That looks like what I need.... I will give it a shot....Thanks!!! -Steve There's a small prob...

Posting values from one web form to another aspx page
How would I post the values from a form in my application to another form in someone elses application using vb.net? I understand it differs from asp 3.0 as pages in asp.net 1.1 post to themselves and a redirect doesn't post the values to the other form. Any help would be appreciated. If its on the same server try Context.Items["name"] = myText; Server.Transfer("page.aspx"); The application is on a different server. Would/Could/Should I have my aspx page redirect to a asp page which would then collect and transmit the values to the "other" app...

Web resources about - Setting the datasource of one dropdown box based on the values selected in another - asp.net.web-forms

Datasource - Wikipedia, the free encyclopedia
A DataSource object has properties that can be modified when necessary. For example, if the data source is moved to a different server, the property ...

Inverness Graham Acquires DataSource
Inverness Graham , a lower middle market private equity firm headquartered in suburban Philadelphia, has acquired DataSource , a print supply ...

SmartGlance for iPad for iPad on the iTunes App Store
Read reviews, get customer ratings, see screenshots, and learn more about SmartGlance for iPad on the App Store. Download SmartGlance for iPad ...

Chaitanya Pandit (@chaitanyapandit) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Data source - Wikipedia, the free encyclopedia
... Data source A data source is any of the following types of sources for (mostly) digitized data: a database in the Java software platform, datasource ...

2ndQuadrant - PostgreSQL expertise from specialists with a source code level understanding of RDBMS ...
PostgreSQL expertise from specialists with a source code level understanding of RDBMS PostgreSQL Planets Gabriele’s PlanetPostgreSQL Gianni’s ...

Tagged entries for CLOUD COMPUTING
Alan Williamson's output as a Java Champion, Blog-City Architect, BlueDragon Creator, Author, Speaker and Internet Guru

Private equity deals
... of biometric identity management systems, applications and services. www.crossmatch.com Inverness Graham Investment has acquired DataSource ...

C# C Sharp and Tutorials on C# Friends.com
Learn the c# langauge to build web applications using our online tutorials with live demos. Participate in our forums and learn from others. ...

JavaScript UI Library, Ajax Components & HTML5 Framework - DHTMLX
DHTMLX offers a rich JavaScript library, UI components & HTML5 mobile framework. Build impressive web apps for both desktop and mobile devices. ...

Resources last updated: 12/11/2015 7:53:56 PM