select/highlight multiple rows listitems.

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

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
 
us listbox.setselected method
example

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

Regards
Martin
 
'System.Web.UI.WebControls.ListBox' does not contain a definition for
'SetSelected'

I get this error? :(
any ideas??

Thanks
Marc
 
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
 
Back
Top