473,503 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DropDownList Im sure Im just missing something

I am new to vb.net here is my problem:

In a windows form I am populating a dropdown list with the
DropDownList1.Items.Add(SomeString) command.
the list populates and looks good however when I attempt to read what the
user has selected it always reads back the first item.

I am attempting to read the answers in a button procedure with the command:
cp = RTrim(DropDownList1.SelectedItem.Text)
Any Idea's why I cant do this?
Nov 21 '05 #1
3 986
I said windows form but I meant to say web form.

"Jeff Buller" wrote:
I am new to vb.net here is my problem:

In a windows form I am populating a dropdown list with the
DropDownList1.Items.Add(SomeString) command.
the list populates and looks good however when I attempt to read what the
user has selected it always reads back the first item.

I am attempting to read the answers in a button procedure with the command:
cp = RTrim(DropDownList1.SelectedItem.Text)
Any Idea's why I cant do this?

Nov 21 '05 #2
Works for me. I put a DDL on the form, a button and a label.

Label1.text = RTrim(DropDownList1.SelectedItem.Text)
The label contains the selected item, works fine.
Perhaps you are doing something weird


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Jeff Buller" <Jeff Bu****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
I am new to vb.net here is my problem:

In a windows form I am populating a dropdown list with the
DropDownList1.Items.Add(SomeString) command.
the list populates and looks good however when I attempt to read what the
user has selected it always reads back the first item.

I am attempting to read the answers in a button procedure with the command: cp = RTrim(DropDownList1.SelectedItem.Text)
Any Idea's why I cant do this?

Nov 21 '05 #3
HAHa Im always doing something wierd
I actually figured is put a couple hours ago form was reloading on button
click clearing selection
the fix is to put "If Not Page.IsPostBack Then"
in the form load
thanks for your time
"One Handed Man ( OHM - Terry Burns )" wrote:
Works for me. I put a DDL on the form, a button and a label.

Label1.text = RTrim(DropDownList1.SelectedItem.Text)
The label contains the selected item, works fine.
Perhaps you are doing something weird


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Jeff Buller" <Jeff Bu****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
I am new to vb.net here is my problem:

In a windows form I am populating a dropdown list with the
DropDownList1.Items.Add(SomeString) command.
the list populates and looks good however when I attempt to read what the
user has selected it always reads back the first item.

I am attempting to read the answers in a button procedure with the

command:
cp = RTrim(DropDownList1.SelectedItem.Text)
Any Idea's why I cant do this?


Nov 21 '05 #4

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

Similar topics

4
1537
by: Iain Kirk | last post by:
Being a bit of a novice any help or pointers would be appreciated. I am building a web page that populates a DropDowList from a table in SQL, for testing purposes i have a simple page that...
18
2422
by: Julia Hu | last post by:
Hi, I have a datagrid, and in different rows I need to programmatically bind different type of controls and load data into these controls. For example,in the first row I need to bind data into a...
7
2016
by: Lastie | last post by:
Hi all, I’ve got a ‘dropdownlist’ web control and I can add ‘listitem’ no problem. I can also bind data from an SQL database fine. My problem is that I want to do both at the same...
2
2128
by: COHENMARVIN | last post by:
I'm leafing through a big book on asp.net, and I don't see any way to the following: 1. bind values and text to a dropdown 2. Also make the first line of the dropdown say something different. For...
6
14302
by: p.mc | last post by:
Hi all, I have a MS SQLServer database which has two tables, 'images' and 'photographers'. The photographer table contains a field for PhotographerID and a one for PhotographerName. The image...
15
3075
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...
2
2266
by: Michael | last post by:
Hi again, I really hope that there is a simple solution to this one, cause I'm having simular things happening to other controls on this usercontrol. I have the following control:...
2
1705
by: cider123 | last post by:
I have a SqlDataSource bound to a DropDownList Combo. Works just fine. I noticed 2 properties you can set in the DropDownList, 1 for the value to be displayed in the "Text" column and 1 for the...
3
12238
by: John Kotuby | last post by:
Hi all... I am trying to do a simple thing and maybe am missing something elementary. I have created a Javascript function at the top of a page which is meant to enable editing of an HTML input...
1
4908
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
7202
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
7280
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,...
1
6991
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
5578
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,...
0
4673
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...
0
3167
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
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
382
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...

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.