473,473 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ASP.NET Dropdownlist BUG???

Hello,

I'm using an ASP.NET dropdown list on my company's "Contact Us" page to
direct certain subjects of emails to different email addresses. The user
selects the subject from a dropdown list, then their email is routed to the
proper person. My code is like this:

<option value="">Select a Topic</option>
<option va******************@website.com>UserID/Password</option>
<option value="in**@website.com">Technical Support</option>
<option value="in**@website.com">Personal Training </option>
<option value="co**@website.com">Become a Club</option>
<option value="me************@website.com">Question for the
Faculty</option>
<option value=in**@website.com>Systems</option>

As you can see the value on some of the options is the same. This is
because some subjects go to the same email addresses. My problem is that
when I try to retrieve the "SelectedItem.Text" in my code-behind, it grabs
the text of the first option in the list this that value. So if i selected
"Personal Training" in the example above, the SelectedItem.Text would be
"Technical Support". Is there anyway around this problem.

Thanks a bunch

-Jason
Nov 19 '05 #1
5 1536
create an array of email addresses in your codebehind, and use the index of
the item in the array instead of the actual email address. Then, when your
page posts back, you look up the real email address from the array using the
value.

--
Pete
====
Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/
Nov 19 '05 #2
Pete,

Thanks so much for your reply. The dropdownlist is actually being populated
being populated by an xml doc right now. I use the DataBind method to fill
the list. Will your suggestion still work?

My XML looks like this:

<item>

<topic>General Help</topic>

<contactperson>in**@website.com</contactperson>

</item>

<item>

<topic>Services</topic>

<contactperson>in**@website.com</contactperson>

</item>

-Jason

"Peter Morris [Droopy eyes software]" <pe**@not.this.or.this.droopyeyes.com>
wrote in message news:e%****************@TK2MSFTNGP14.phx.gbl...
create an array of email addresses in your codebehind, and use the index
of the item in the array instead of the actual email address. Then, when
your page posts back, you look up the real email address from the array
using the value.

--
Pete
====
Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/

Nov 19 '05 #3
Jason Dean wrote:
Hello,

I'm using an ASP.NET dropdown list on my company's "Contact Us" page to
direct certain subjects of emails to different email addresses. The user
selects the subject from a dropdown list, then their email is routed to the
proper person. My code is like this:

<option value="">Select a Topic</option>
<option va******************@website.com>UserID/Password</option>
<option value="in**@website.com">Technical Support</option>
<option value="in**@website.com">Personal Training </option>
<option value="co**@website.com">Become a Club</option>
<option value="me************@website.com">Question for the
Faculty</option>
<option value=in**@website.com>Systems</option>

As you can see the value on some of the options is the same. This is
because some subjects go to the same email addresses. My problem is that
when I try to retrieve the "SelectedItem.Text" in my code-behind, it grabs
the text of the first option in the list this that value. So if i selected
"Personal Training" in the example above, the SelectedItem.Text would be
"Technical Support". Is there anyway around this problem.

Thanks a bunch

-Jason


Remember, asp.net only works on the server. The browser sees
a regular <select> element. When you (the user) selects one
option, then just the selected value is returned to the
server. asp.net has no way to know if this was the first or
second occurrence of this value.

--
Hans Kesting
Nov 19 '05 #4
So what's your suggestion to getting around this problem?

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Jason Dean wrote:
Hello,

I'm using an ASP.NET dropdown list on my company's "Contact Us" page to
direct certain subjects of emails to different email addresses. The user
selects the subject from a dropdown list, then their email is routed to
the proper person. My code is like this:

<option value="">Select a Topic</option>
<option va******************@website.com>UserID/Password</option>
<option value="in**@website.com">Technical Support</option>
<option value="in**@website.com">Personal Training </option>
<option value="co**@website.com">Become a Club</option>
<option value="me************@website.com">Question for the
Faculty</option>
<option value=in**@website.com>Systems</option>

As you can see the value on some of the options is the same. This is
because some subjects go to the same email addresses. My problem is that
when I try to retrieve the "SelectedItem.Text" in my code-behind, it
grabs the text of the first option in the list this that value. So if i
selected "Personal Training" in the example above, the SelectedItem.Text
would be "Technical Support". Is there anyway around this problem.

Thanks a bunch

-Jason


Remember, asp.net only works on the server. The browser sees
a regular <select> element. When you (the user) selects one
option, then just the selected value is returned to the
server. asp.net has no way to know if this was the first or
second occurrence of this value.

--
Hans Kesting

Nov 19 '05 #5
While not necessarily elegant, you could always use a simple cheat. When the
list is generated from a dataset you could walk the rows (for each construct
works well) and pop a unique prefix on each value. For example, using the
row ordinal, you could create the following values:

0~***************@website.com
1~****@website.com
etc.

Then, when the post occurs, simply split the value and discard the first
element of the array on the tilde (or another character you know is safe).
The second element contains your formed email address, and you'll always
have a unique selection to return the correct Text property.

F Buchan

"Jason Dean" <jd******@yahoo.com> wrote in message
news:Hb*******************@fe06.lga...
Hello,

I'm using an ASP.NET dropdown list on my company's "Contact Us" page to
direct certain subjects of emails to different email addresses. The user
selects the subject from a dropdown list, then their email is routed to
the proper person. My code is like this:

<option value="">Select a Topic</option>
<option va******************@website.com>UserID/Password</option>
<option value="in**@website.com">Technical Support</option>
<option value="in**@website.com">Personal Training </option>
<option value="co**@website.com">Become a Club</option>
<option value="me************@website.com">Question for the
Faculty</option>
<option value=in**@website.com>Systems</option>

As you can see the value on some of the options is the same. This is
because some subjects go to the same email addresses. My problem is that
when I try to retrieve the "SelectedItem.Text" in my code-behind, it grabs
the text of the first option in the list this that value. So if i
selected "Personal Training" in the example above, the SelectedItem.Text
would be "Technical Support". Is there anyway around this problem.

Thanks a bunch

-Jason

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
2
by: Shiju Poyilil | last post by:
Hello, I have a datagrid with only one row and its having 2 dropdownlists, I need to populate the secodn dropdownlist on the basis of the selection in the first dropdown. but I am not able to...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
15
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
1
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over...
0
by: asmx126453 | last post by:
Hey mensen I am having some big troubles here i tryd solving it myself with internet for 2 days but i kind fix it. Its about this i have a DotNet project that alrydi is online and working for...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.