By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

select/highlight multiple rows listitems.

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
'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

P: n/a
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.