Sending email uses the first value in drop down list instead of value selected by the user

I have a web form with a dropdownbox, when the user clicks submit, I insert into a database, and send an email confirmation.  But, I can't get the value the user selects for the dropdownbox.  Instead, it's always the first value in the dynamic drop down box. 

 Here's the code for the part of the email where I'm trying to get the text associated with the value they select from the drop down list.  Any ideas why I always get the first value in the drop down list for RequestingAttorney? 

sString += "Type of search:&nbsp;&nbsp;&nbsp;" & SearchTypeID.SelectedItem.Text & "<BR/>Requesting Attorney:&nbsp;&nbsp;&nbsp;" & RequestingAttorney.SelectedItem.Text & "<br/><HR><br/>"


Never make important decisions on a Monday!
0
funluckykitty
7/22/2008 6:27:05 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

2 Replies
716 Views

Similar Articles

[PageSpeed] 27

When you populate the Dropdownlist - if you are populating it in the Page_load event, make sure that it is enclosed within an if/then/postback block

(http://www.aspnet101.com/aspnet101/tutorials.aspx?id=3)


David Wier
MCP/ASPInsider
ASPNet101.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 HTML Calendar Generator on the web!
(Please 'Mark as Answer' when it applies)
0
augustwind
7/22/2008 6:39:18 PM

doh...  I had this....

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack Then
RequestingAttorney.DataBind()
End If
End Sub

 Instead of

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
RequestingAttorney.DataBind()
End If
End Sub


Never make important decisions on a Monday!
0
funluckykitty
7/22/2008 6:47:47 PM
Reply:

Similar Artilces:

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

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

Drop Down List Web User Control: How to access the selected value
With a texbox user control, the method for accessing text keyed in doesn't work for accessing the selection made on a drop down menu. This is because an event is fired with the drop down listbox, as compared to the textbox where no event is fired. Here's how to read the selection made in the drop down list control and make it available to the page containing it. It works for me. -- In the .aspx page (user_control_exp.aspx), hosting the Web user control (a drop down list box): -- <code> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Hand...

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

Selecting a Value in a Drop Down List Based on the Value of a Textbox
I have a formview control (.NET 2.0/VS2005) in which users enter company contact information.  When a user enters a postal code in the appropriate text box, the territory for that company needs to be calculated and displayed in a territory drop down list. I know how to calculate and retrieve the territory from my SQL Server database, but I can't seem to nail down how to trigger the code and don't want the user to have to click a button. I tried using the OnTextChanged event, but that doesn't seem to be what I want because I need this calculation to be performed pri...

DropDown list submits first value not the selected value
I am relatively new to programming and am having a problem with a small project that I am working on.  I have a names drop down list that is created from a database.  When the user selects a name and completes the rest of the form and clicks submit.  All of the data they entered is submitted to a different table in that database.  This is workign correctly for all of the data except the drop down.  For some reason the first value in the drop down is being submitted each time.  Here is the code and any help you can give will be appreciated. Public Class final1 ...

Cascading Dropdown List
Hi, First post so hello and need some help with an issue I have been dealing with.  I have an intranet page I created in ASP.NET using C# .NET 3.5 with a few Ajax Extenders including 3 Cascading Dropdown Lists. Now I have used the Cascading dropdown lists for my own purposes i.e they do not actually cascade their results to another dropdown list, the reason I did this was due to the having a User Control that contains an update panel and other bits i.e I didn't want the control/page posting page (something that happens when you click on a regular dropdown list). Everything is wor...

Drop down list control values OK but not showing selected value on UI
 Hi, I am having trouble with the following: ddlIndustry.Items.FindByText(oReader["industry"].ToString()).Selected = true;  I am trying to get the ddlIndustry drop down list to bind to a specific product industry got from a database like say "Agriculture". Even when i assign a hardwired and existent value like "Agriculture" as from the database,  the Selected value or text does change from initial option from the list with (this I verified in Debug mode) but when the page is generated, the Drop down list maintains value 0 and text "--select one --". Is there something i am...

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

How do I use javascript to set the selected value of a drop down list?
I have a drop down list with several options.  Normally the user selects a value, however, there are certain other controls on the page that need to force the selection of a specific value on the drop down list. How would I do this with javascript? Hi, Do you need to validate the dropdown such that on click of any of the button you need to say that atleast one option should be selected? If it so, you could use thisvar ddlTest = document.getElementById('<%= ddlTest.ClientID %>'); if ( ddlTest.options.length == 0 ) { // Here you can alert the user to select on...

Insert uses pageload selected value instead of actual value at time of button submit.
I have a drop down box that by default selects the submitting person's id when the page loads.  However, if the person using the form is submitting it for someone else, they have the option of changing the value in the drop down list.  The problem I'm having is when the data is inserted into the database, the original selected index value is ALWAYS submitted, even if the user selects someone else.   How to I tell my codebehind to check the value before it's submitted to see if it changed after the page loaded?  Never make important decisions on a Mon...

Using property values of user control between two web forms.
Hi,I am stuck with a problem.I have a user control on more than one web form( say webform1 and webform2 ).The user control consists of several hyperlinks(say hyp1 and hyp2 ).When I enter values in webform1 and then click 'save' button , one of the property of user control (say ID ) is assigned some value. I want to use that value 'ID' in webform2 after the user clicks on hyp2. I dont think using Querystring will be useful because hyp1 is selected be default. It is not a compulsion for the user, that he has to click on hyp2..he can also click on other hyperlinks of the user control also...Ple...

Selected value in select list with javascript based off value in database
 I've got a classic asp page with a select list. I need the select list's selected value to be whatever the user selected when they created their account. I've been trying to use <body onLoad="onLoad();"> to call my function, and then I'm trying to specify which value should be selected in the function. Also, when the select list selected values change, there is a javascript function I call to disable text boxes. I think there is an issue with my javascript function, and I can't find any examples of this from good ole' google.  My j...

Web resources about - Sending email uses the first value in drop down list instead of value selected by the user - asp.net.web-forms

Portal:Law/Nominate/Selected article - Wikipedia, the free encyclopedia
Add the article in to a subpage of this portal, such as Portal:Law/Selected article/# , replacing the "#" with the number above the current highest. ...

F8: Facebook’s FbStart Initiative Will Give Selected Developers A $30K Kick-Start
... successful applications is likely a whole lot easier with $30,000 in free tools and services to start off with, and that’s exactly what selected ...

LEGO Shop - The LEGO Technic team has selected the winner... - Facebook
The LEGO Technic team has selected the winner of the Co-Creation Challenge! LEGO will be producing a limited run of 20,000 of this stunning set.... ...

baby365- Grand Doctor Ma Selected Students for iPad on the iTunes App Store
Get baby365- Grand Doctor Ma Selected Students on the App Store. See screenshots and ratings, and read customer reviews.

Selected Cheney Vice Presidential Photographs
... for photos found within these albums are Paul Morse, Karen Ballard, Kimberlee Hewitt, Shealah Craighead, and Chris Greenberg. These selected ...

[iOS Advice] How To Clarify Your Email Replies By Quoting Selected Text - YouTube
Follow me on Twitter: http://www.twitter.com/macmixing Like my Facebook page: http://www.facebook.com/macmixing RATE, COMMENT, SUBSCRIBE! :-) ...

Sait Faik Abasıyanık’s Selected Stories are tales that beguile all for their brevity
The influential Turkish writer's collection of short stories is often bizzare but never boring.

Animal of the Day: Lucius Has Been Selected as the U.K.’s ‘Happiest Cat’
He’s got one blue eye, one green eye and a heart of gold. British mobile phone company O2 recently held some “cat auditions” to find “the UK’s ...

Michael Sam becomes first openly gay player selected in an NFL Draft
Defensive end Michael Sam of the University of Missouri became the first openly gay player to be selected in a National Football League Draft ...

Refugee spinner selected for PM's XI
Fawad Ahmed has gone from asylum seeker to rubbing shoulders with Julia Gillard at The Lodge.

Resources last updated: 12/17/2015 4:15:26 AM