Pre select multiple listbox items(newbie)

  • Thread starter Thread starter Angela
  • Start date Start date
A

Angela

Hi

I am having trouble doing this simple task:

What I want to do is pre select the listbox called ltbLanguage (which
allows multiple selections).

while dtr.read()
for i = 0 to dtr.fieldcount-1
ltbLanguage.selectedIndex = dtr("language_id")
next
end while

At the moment it is only selecting one item even though there is more
than one record returned from the DB

Thanks

Angela
 
Hi Angela

Sample code in ASP.NET with C# for ur req
(ltbLanguage -> ListBox control (Web Control)

ListItem lstItem = null

while (dtr.read()

for (i = 0;i< dtr.fieldcount-1;i++

lstItem = ltbLanguage.Items.FindByValue(dtr("language_id").ToString());
if (lstItem != null

lstItem.Selected = true




You can also use the FindByName() function if ur search is based on Text value of the ListBox

Hope this cud help u out. Let me know, if ur req. is not in C# language

Regards
Kamalanathan T
 
Back
Top