473,567 Members | 2,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DropDownList SelectedItem Problem

Hi,
I have a problem with a page which has about 50 web controls , 12 of the are
DropDownList.
Also, I have a "Continue" button, and on the server code an event sub
btnContinue_Cli ck, where I process the input data.
There is a code like :

Dim MyVariable As Integer
Dim AnOtherVariable As Integer
MyVariable = DropDownList1.S electedItem.Val ue
AnOtherVariable = DropDownList2.S electedItem.Val ue

Can anyone help?
Nov 18 '05 #1
4 1709
The Problem is that allways I get 1, that is the first item selected, no
matter wich exactly is selected
"Ivan" <iz*****@hotmai l.com> wrote in message
news:er******** *****@TK2MSFTNG P09.phx.gbl...
Hi,
I have a problem with a page which has about 50 web controls , 12 of the are DropDownList.
Also, I have a "Continue" button, and on the server code an event sub
btnContinue_Cli ck, where I process the input data.
There is a code like :

Dim MyVariable As Integer
Dim AnOtherVariable As Integer
MyVariable = DropDownList1.S electedItem.Val ue
AnOtherVariable = DropDownList2.S electedItem.Val ue

Can anyone help?

Nov 18 '05 #2
You don't state what the problem is, but judging from the
code sample you provided, I'd say you need to convert the
selected value to an integer.

You'll need something like the following:

MyVar = Integer.Parse(D ropDownList1.Se lectedItem.Valu e)
-----Original Message-----
Hi,
I have a problem with a page which has about 50 web controls , 12 of the areDropDownList .
Also, I have a "Continue" button, and on the server code an event subbtnContinue_Cl ick, where I process the input data.
There is a code like :

Dim MyVariable As Integer
Dim AnOtherVariable As Integer
MyVariable = DropDownList1.S electedItem.Val ue
AnOtherVariabl e = DropDownList2.S electedItem.Val ue

Can anyone help?
.

Nov 18 '05 #3
Are you populating the drop down lists dynamically? I've
had similar problems when I accidentally put the
population code in the PageLoad event and did not protect
it with a test for IsPostBack.

-Roger
-----Original Message-----
The Problem is that allways I get 1, that is the first item selected, nomatter wich exactly is selected
"Ivan" <iz*****@hotmai l.com> wrote in message
news:er******* ******@TK2MSFTN GP09.phx.gbl...
Hi,
I have a problem with a page which has about 50 web controls , 12 of the
are
DropDownList.
Also, I have a "Continue" button, and on the server

code an event sub btnContinue_Cli ck, where I process the input data.
There is a code like :

Dim MyVariable As Integer
Dim AnOtherVariable As Integer
MyVariable = DropDownList1.S electedItem.Val ue
AnOtherVariable = DropDownList2.S electedItem.Val ue

Can anyone help?

.

Nov 18 '05 #4

It works now :)
IsPostBack was the problem

Thanks

"R Warford" <an*******@disc ussions.microso ft.com> wrote in message
news:0f******** *************** *****@phx.gbl.. .
Are you populating the drop down lists dynamically? I've
had similar problems when I accidentally put the
population code in the PageLoad event and did not protect
it with a test for IsPostBack.

-Roger
-----Original Message-----
The Problem is that allways I get 1, that is the first

item selected, no
matter wich exactly is selected
"Ivan" <iz*****@hotmai l.com> wrote in message
news:er******* ******@TK2MSFTN GP09.phx.gbl...
Hi,
I have a problem with a page which has about 50 web controls , 12 of the
are
DropDownList.
Also, I have a "Continue" button, and on the server

code an event sub btnContinue_Cli ck, where I process the input data.
There is a code like :

Dim MyVariable As Integer
Dim AnOtherVariable As Integer
MyVariable = DropDownList1.S electedItem.Val ue
AnOtherVariable = DropDownList2.S electedItem.Val ue

Can anyone help?

.

Nov 18 '05 #5

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

Similar topics

1
6304
by: DC Gringo | last post by:
I'm having such a problem with this DropDownList in a user control that is posting back and throwing an error: System.Web.HttpException: A DropDownList cannot have multiple items selected <ASP:DROPDOWNLIST ID="lbCountriesWiz" ENABLEVIEWSTATE="true" FONT-SIZE="8pt" ONSELECTEDINDEXCHANGED="ddlQueryProvinces" AUTOPOSTBACK="True"...
4
7446
by: theo | last post by:
Program flow...load file,then extract the xml text tags from the file,then the number of Xml tags retrieved from the file determines the number of dropdownlist controls instanciated in the placeholder,the user selects the required tags from the dropdownlists (if 5 Xml tags,then 5 dropdownlists each containing 5 xml tags) and now the...
0
1969
by: huobazi | last post by:
I have many dropdownlist controls in my ascx (and use LoadControl in a aspx fiel) file,so i write a method "InitList(DropDownList list,string strsql,string TextField,string ValueField)" but when i want to get the BigClassList.SelectedItem.Text and BigClassList.SelectedItem.Value in a button onclick method,btnSmallClassEdit_Click(....),there post...
3
2177
by: Randy Armknecht | last post by:
The problem is that when the SelectedIndex is changed, it posts back the page. It does not however fire the OnSelectedIndexChanged event, and it does NOT keep the state of the item that was selected in the DDL. DropDownList looks like this: <asp:dropdownlist id="DropDown" Runat="server" AutoPostBack="True"></asp:dropdownlist> The...
10
10727
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected = true; Where endTime is a string containing "15".
1
1144
by: vladp | last post by:
Hi! Here is problem I got. I use vb.net and MSSQL Server 2000. My dropdownlist box gets information from view, and it works. However when I am trying to get information from the dropdownlist I get error message. Also during step by step debug dropPP.SelectedItem.Text gets value "NOTHING" Object reference not set to an instance of an...
2
2173
by: Antonio D'Ottavio | last post by:
Good morning, I've a problem with a dropdownlist located inside any row of a datalist, I fill both datalist and dropdownlist at runtime, the problem is with the dropdownlist infact using the event OnItemDataBound I can fill it but it is impossible for me to load the right selectedItem.Value , infact looking at the html page produced by the...
4
2025
by: ^MisterJingo^ | last post by:
Hi all, I have a web page which has a single dropdownlist containing 3 items. Below the dropdownlist are two listboxes. Depending on the option selected from the dropdownlist, the left most listbox populates itself from a DB table, assigning the correct id to each item as a value. In between the listboxes are two buttons. On clicking an...
1
4645
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 ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be...
0
3486
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- 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 ,another row...
0
7688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7590
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7905
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5216
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3648
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3630
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2093
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 we have to send another system
0
930
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.