473,569 Members | 2,611 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.I tems.Add(SomeSt ring) 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(DropDownL ist1.SelectedIt em.Text)
Any Idea's why I cant do this?
Nov 21 '05 #1
3 989
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.I tems.Add(SomeSt ring) 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(DropDownL ist1.SelectedIt em.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(DropDownL ist1.SelectedIt em.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****@discussi ons.microsoft.c om> wrote in message
news:57******** *************** ***********@mic rosoft.com...
I am new to vb.net here is my problem:

In a windows form I am populating a dropdown list with the
DropDownList1.I tems.Add(SomeSt ring) 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(DropDownL ist1.SelectedIt em.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(DropDownL ist1.SelectedIt em.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****@discussi ons.microsoft.c om> wrote in message
news:57******** *************** ***********@mic rosoft.com...
I am new to vb.net here is my problem:

In a windows form I am populating a dropdown list with the
DropDownList1.I tems.Add(SomeSt ring) 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(DropDownL ist1.SelectedIt em.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
1540
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 displays a datagrid with the same data, now this does work so i know the data is there but the dropdownlist is empty. If anyone could show me where i'm...
18
2430
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 textbox, and in the second row I need to bind data into a dropdownlist...It all depends on the data I select from the database. I cannot use...
7
2023
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 time to allow me to have the first option in the list a ‘listitem’ saying something like ‘please pick an option’, and then the rest of options...
2
2140
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 instance, if I'm working with a table of hotels, I might want a 'select' control as follows <select id="mylistbox" runat="server"> <option...
6
14306
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 table also contains a field for photographerID which is used to join the two tables. I'm having problems with populating a dropDownList using the...
15
3085
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 OnSelectedIndex event is not fired if you select the first item. Does anyone know of an easy way to do this?
2
2272
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: <asp:DropDownList ID="cmbOptions" runat="server" Width="195px"> <asp:ListItem Text="Search by PO ID" Value=0 Selected="True" /> <asp:ListItem Text="Search by...
2
1713
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 value to be used in the "Value" property. I'm at a catch 22 right now though.. The SqlDataSource gets 2 field values.. "Name" and "Description".
3
12244
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 textbox when the user makes a selection from the DropDownList control. Since there is no OnClick event I have tried using OnSelectedIndexChanged or...
1
4915
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 time. The problem is that when an item has been removed from the lookup table, and a user wants to retrieve a record that used the deleted item,...
0
7614
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
7924
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
8125
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7974
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
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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
3653
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...
1
2114
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

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.