-
How to get a selected value of a dropdown list
I was wondering if anyone could tell me how to get the value of the item selected
from a listbox or a Dropdownlistbox. This is very is to do in vb6 but I am
having lots of problems in the vb.net. I appreciate the help.
If at all possible I'd like to stick with the vb coding and away from HTML
Please reply to
sroozrokh@18004insure.com
Thanks
-
Re: How to get a selected value of a dropdown list
Since I'm not exactly sure which listbox or dropdownlist you're talking
about...
For WebControls, use the SelectedItem.Value property
For HtmlControls, use the Value property (though you might have to something
different with a multi-select enabled list box).
For windows forms, use the SelectedValue property
"shawn" <sroozrokh@3704@18004insure.com> wrote in message
news:3d4efd66$1@10.1.10.29...
>
> I was wondering if anyone could tell me how to get the value of the item
selected
> from a listbox or a Dropdownlistbox. This is very is to do in vb6 but I am
> having lots of problems in the vb.net. I appreciate the help.
>
> If at all possible I'd like to stick with the vb coding and away from HTML
> Please reply to
>
> sroozrokh@18004insure.com
> Thanks
-
Re: How to get a selected value of a dropdown list
"shawn" <sroozrokh@3704@18004insure.com> wrote in message
news:3d4efd66$1@10.1.10.29...
>
> I was wondering if anyone could tell me how to get the value of the item
selected
> from a listbox or a Dropdownlistbox. This is very is to do in vb6 but I am
> having lots of problems in the vb.net. I appreciate the help.
>
> If at all possible I'd like to stick with the vb coding and away from HTML
Hi there.
Make up a new standard windows project, and add a listbox and a command
button to the form.
Then add this code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ListBox1.Items.Add("Sausage")
ListBox1.Items.Add("Burger")
ListBox1.Items.Add("Pie")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MessageBox.Show(ListBox1.SelectedItem.ToString)
End Sub
run your app, select a list item, and press the button.
Hopefully this will get you started.
-
Re: How to get a selected value of a dropdown list
"the localhost with the most" <local@host.com> wrote:
>"shawn" <sroozrokh@3704@18004insure.com> wrote in message
>news:3d4efd66$1@10.1.10.29...
>>
>> I was wondering if anyone could tell me how to get the value of the item
>selected
>> from a listbox or a Dropdownlistbox. This is very is to do in vb6 but
I am
>> having lots of problems in the vb.net. I appreciate the help.
>>
>> If at all possible I'd like to stick with the vb coding and away from
HTML
>
>Hi there.
>Make up a new standard windows project, and add a listbox and a command
>button to the form.
>Then add this code:
>
>Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles MyBase.Load
> ListBox1.Items.Add("Sausage")
> ListBox1.Items.Add("Burger")
> ListBox1.Items.Add("Pie")
>End Sub
>
>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles Button1.Click
> MessageBox.Show(ListBox1.SelectedItem.ToString)
>End Sub
>
>run your app, select a list item, and press the button.
>
>Hopefully this will get you started.
>
>
Hi,
Just to clarify, there are two things available from the selected item.
You can get the text or the value of the selected item. In the dropdown
list you can assign a value such as an index number to each list item, and
there is the text value as well.
To access the text: dropdownlist.SelectedItem.ToString
To access the value: dropdownlist.SelectedItem.Value
Rodney
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks