469,607 Members | 1,953 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

select/highlight multiple rows listitems.

How do i do the following:

lbCountries.SelectedValue = "826";

lbCountries.SelectedValue = "840";

Basically i've set the selectmode to multiple and want to select multiple
values of the listbox on databind.

the problem is this only selects the last row "840" -- i would imagine this
would happen because i'm just replacing the value of selectedvalue. Does
anyone know how to select multiple values?

thanks all in advance

Marc

Nov 16 '05 #1
3 5471
us listbox.setselected method
example

lbCountries.SetSelected ( lbCountries.FindStringExact("826"), True )
lbCountries.SetSelected ( lbCountries.FindStringExact("840"), True )

Regards
Martin
"mike" <sp******@hotmail.com> wrote in message
news:X0*******************@doctor.cableinet.net...
How do i do the following:

lbCountries.SelectedValue = "826";

lbCountries.SelectedValue = "840";

Basically i've set the selectmode to multiple and want to select multiple
values of the listbox on databind.

the problem is this only selects the last row "840" -- i would imagine this would happen because i'm just replacing the value of selectedvalue. Does
anyone know how to select multiple values?

thanks all in advance

Marc

Nov 16 '05 #2
'System.Web.UI.WebControls.ListBox' does not contain a definition for
'SetSelected'

I get this error? :(
any ideas??

Thanks
Marc

"Martin Marinov" <me********@mecrossroad.bg> wrote in message
news:OD**************@TK2MSFTNGP12.phx.gbl...
us listbox.setselected method
example

lbCountries.SetSelected ( lbCountries.FindStringExact("826"), True )
lbCountries.SetSelected ( lbCountries.FindStringExact("840"), True )

Regards
Martin
"mike" <sp******@hotmail.com> wrote in message
news:X0*******************@doctor.cableinet.net...
How do i do the following:

lbCountries.SelectedValue = "826";

lbCountries.SelectedValue = "840";

Basically i've set the selectmode to multiple and want to select multiple values of the listbox on databind.

the problem is this only selects the last row "840" -- i would imagine

this
would happen because i'm just replacing the value of selectedvalue. Does
anyone know how to select multiple values?

thanks all in advance

Marc


Nov 16 '05 #3
Sorry, I was thinking of windows programing and windows ListBox

For web Listbox control you have to use
lbCountries.Items.FindByValue("826").Selected = true;

lbCountries.Items.FindByValue("840").Selected = true;

instead of

lbCountries.SetSelected ( lbCountries.FindStringExact("826"), True )
lbCountries.SetSelected ( lbCountries.FindStringExact("840"), True )

Hope This Helps
Regards
Martin

"mike" <sp******@hotmail.com> wrote in message
news:7D*******************@doctor.cableinet.net...
'System.Web.UI.WebControls.ListBox' does not contain a definition for
'SetSelected'

I get this error? :(
any ideas??

Thanks
Marc

"Martin Marinov" <me********@mecrossroad.bg> wrote in message
news:OD**************@TK2MSFTNGP12.phx.gbl...
us listbox.setselected method
example

lbCountries.SetSelected ( lbCountries.FindStringExact("826"), True )
lbCountries.SetSelected ( lbCountries.FindStringExact("840"), True )

Regards
Martin
"mike" <sp******@hotmail.com> wrote in message
news:X0*******************@doctor.cableinet.net...
How do i do the following:

lbCountries.SelectedValue = "826";

lbCountries.SelectedValue = "840";

Basically i've set the selectmode to multiple and want to select multiple values of the listbox on databind.

the problem is this only selects the last row "840" -- i would imagine

this
would happen because i'm just replacing the value of selectedvalue. Does anyone know how to select multiple values?

thanks all in advance

Marc



Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bob Hollness | last post: by
4 posts views Thread by Matt Ratliff | last post: by
2 posts views Thread by Andy Baker | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.