473,396 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Any way to have a ListBox with nothing selected?

I need to have a control (currently trying to use listbox) where the user
can have nothing selected if they choose. Any way to do that with a list box
or would I be better off with a RadioButtonList? Any other bound controls I
should look into?

Thanks!
Nov 18 '05 #1
7 5938
deselect the listbox by setting the selectedindex to -1 in code

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"MattB" <so********@yahoo.com> wrote in message
news:2m************@uni-berlin.de...
I need to have a control (currently trying to use listbox) where the user
can have nothing selected if they choose. Any way to do that with a list
box
or would I be better off with a RadioButtonList? Any other bound controls
I
should look into?

Thanks!

Nov 18 '05 #2
Usually easiest done by adding an empty item at position zero after binding,
at leat that way the user can select nothing as an option

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"MattB" <so********@yahoo.com> wrote in message
news:2m************@uni-berlin.de...
I need to have a control (currently trying to use listbox) where the user
can have nothing selected if they choose. Any way to do that with a list box or would I be better off with a RadioButtonList? Any other bound controls I should look into?

Thanks!

Nov 18 '05 #3
Alvin Bruney [MVP] wrote:
deselect the listbox by setting the selectedindex to -1 in code
I need to have a control (currently trying to use listbox) where the
user can have nothing selected if they choose. Any way to do that
with a list box
or would I be better off with a RadioButtonList? Any other bound
controls I
should look into?

Thanks!


Thanks to you both!

Matt
Nov 18 '05 #4
Hi, just wondering how to add an empty item at position 0 after data binding as I have a listbox that is currently setup with a databind, after using a stored procedure to fill a dataset?
Thanks.
--
Paul G
Software engineer.
"John Timney (Microsoft MVP)" wrote:
Usually easiest done by adding an empty item at position zero after binding,
at leat that way the user can select nothing as an option

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"MattB" <so********@yahoo.com> wrote in message
news:2m************@uni-berlin.de...
I need to have a control (currently trying to use listbox) where the user
can have nothing selected if they choose. Any way to do that with a list

box
or would I be better off with a RadioButtonList? Any other bound controls

I
should look into?

Thanks!


Nov 18 '05 #5
I agree with John on the the empty item for the scenario if a user selects and item and decides to not select something, then the listbox would save that item selected. This would not leave the user a choice unselect their initial choice.
"John Timney (Microsoft MVP)" wrote:
Usually easiest done by adding an empty item at position zero after binding,
at leat that way the user can select nothing as an option

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"MattB" <so********@yahoo.com> wrote in message
news:2m************@uni-berlin.de...
I need to have a control (currently trying to use listbox) where the user
can have nothing selected if they choose. Any way to do that with a list

box
or would I be better off with a RadioButtonList? Any other bound controls

I
should look into?

Thanks!


Nov 18 '05 #6
With ddlRoutes
.DataSource = travelDB.GetRoutes
.DataTextField = "RouteName"
.DataValueField = "RouteID"
.DataBind()

.Items.Insert(0, New ListItem("-select route-", ""))
End With

HTH,
Greg

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:A6**********************************@microsof t.com...
Hi, just wondering how to add an empty item at position 0 after data binding as I have a listbox that is currently setup with a databind, after
using a stored procedure to fill a dataset? Thanks.
--
Paul G
Software engineer.
"John Timney (Microsoft MVP)" wrote:
Usually easiest done by adding an empty item at position zero after binding, at leat that way the user can select nothing as an option

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"MattB" <so********@yahoo.com> wrote in message
news:2m************@uni-berlin.de...
I need to have a control (currently trying to use listbox) where the user can have nothing selected if they choose. Any way to do that with a
list box
or would I be better off with a RadioButtonList? Any other bound
controls I
should look into?

Thanks!


Nov 18 '05 #7
ok thanks it worked!
--
Paul G
Software engineer.
"Greg Burns" wrote:
With ddlRoutes
.DataSource = travelDB.GetRoutes
.DataTextField = "RouteName"
.DataValueField = "RouteID"
.DataBind()

.Items.Insert(0, New ListItem("-select route-", ""))
End With

HTH,
Greg

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:A6**********************************@microsof t.com...
Hi, just wondering how to add an empty item at position 0 after data

binding as I have a listbox that is currently setup with a databind, after
using a stored procedure to fill a dataset?
Thanks.
--
Paul G
Software engineer.
"John Timney (Microsoft MVP)" wrote:
Usually easiest done by adding an empty item at position zero after binding, at leat that way the user can select nothing as an option

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"MattB" <so********@yahoo.com> wrote in message
news:2m************@uni-berlin.de...
> I need to have a control (currently trying to use listbox) where the user > can have nothing selected if they choose. Any way to do that with a list box
> or would I be better off with a RadioButtonList? Any other bound controls I
> should look into?
>
> Thanks!
>
>


Nov 18 '05 #8

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

Similar topics

4
by: Alienz | last post by:
I have a subform where I have a subform with 20 options to select from. When I set the multiselect property to simple and select multiple options, nothing is stored. I have another table with...
2
by: Sally | last post by:
I have a simple multiselect listbox with a rowsorce of MemberID, MemberName, SendLetter. SendLetter is a Yes/No field. What is the code to set SendLetter to Yes when the user selects MemberName? I...
2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
4
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item,...
4
by: collie | last post by:
HI, I need to populate 2 listboxes from a db. When the page loads then the first listbox needs to be populated and based on selection from that listbox the second listbox needs to be populated...
11
by: Zorpiedoman | last post by:
The problem is this: I have a list box. I set an array list as the datasource. I remove an item from the array list. I set the listbox datasource to nothing. I set the listbox datasource to...
2
by: php_Boi | last post by:
i have designed an application that is a dynamic submission form. i have text fields and listboxes. now i am able to retain the values of the listboxes when i populate the listbox "manually"(single...
9
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
1
by: dkohel | last post by:
I have 2 list boxes on my form. I am trying to populate listbox B with the selection from listbox A. I have set multi-select in both boxes to Extended... The user will select the items from...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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...
0
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...

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.