Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Pre select multiple listbox items(newbie)

Reply
Thread Tools

Pre select multiple listbox items(newbie)

 
 
Angela
Guest
Posts: n/a
 
      06-03-2004
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
 
Reply With Quote
 
 
 
 
Vidar Petursson
Guest
Posts: n/a
 
      06-03-2004
Hi

myListBox.Items[ iIndex ].Selected = true;

--
Best Regards
Vidar Petursson
==============================
Microsoft Visual: Scripting MVP 2000-2004
http://www.icysoft.com/
http://www.deus-x.com/ Instant e-commerce
http://www.microsoft.com/technet/scriptcenter/
Playground: http://213.190.104.211/ ( IE 5.5+ only )

No matter where you go there you are
==============================
"Angela" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2FtYWx0?=
Guest
Posts: n/a
 
      06-03-2004
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").T oString());
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

 
Reply With Quote
 
Angela Lam
Guest
Posts: n/a
 
      06-03-2004
I am using VB

Angela



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Angela Lam
Guest
Posts: n/a
 
      06-03-2004
Thanks for your help guys, figured it out!!



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox move multiple selected items to second listbox K B ASP .Net 2 01-08-2007 11:16 AM
Tkinter: select multiple entries in Listbox widget? Bernard Lebel Python 3 06-02-2006 12:56 PM
Help with Multiple Select ListBox sab ASP .Net 1 08-02-2005 10:15 PM
Multiple select listbox values in query DC Gringo ASP .Net 2 04-14-2004 06:28 AM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM



Advertisments