Pre select multiple listbox items(newbie)

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top