Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Returning the index number of listbox

Reply
Thread Tools

Returning the index number of listbox

 
 
Maziar Aflatoun
Guest
Posts: n/a
 
      05-13-2005
Hi,

Does anyone know how I can return the index number of a ListBox?

Ex. How do I use lbxMyListBox.Items.IndexOf to search for the item that has
a Text="Name"

Thanks
Maz.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9u?=
Guest
Posts: n/a
 
      05-13-2005
Could you not do this whith a foreach?

Jon

"Maziar Aflatoun" wrote:

> Hi,
>
> Does anyone know how I can return the index number of a ListBox?
>
> Ex. How do I use lbxMyListBox.Items.IndexOf to search for the item that has
> a Text="Name"
>
> Thanks
> Maz.
>
>
>

 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      05-13-2005
Dim index As Integer =
lbxMyListBox.Items.IndexOf(lbxMyListBox.Items.Find ByText("Name"))

If you need to look for a value instead of text, use FindByValue method

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU


"Maziar Aflatoun" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> Does anyone know how I can return the index number of a ListBox?
>
> Ex. How do I use lbxMyListBox.Items.IndexOf to search for the item that
> has a Text="Name"
>
> Thanks
> Maz.
>
>



 
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
sorting index-15, index-9, index-110 "the human way"? Tomasz Chmielewski Perl Misc 4 03-04-2008 05:01 PM
Listbox item added with client scripts not submitting with ASP:Listbox Simon Prince ASP .Net 2 10-19-2004 04:11 PM
How do I move all items in a listbox to another listbox kent ASP .Net 1 05-03-2004 12:17 AM
click listbox and refresh another listbox DC Gringo ASP .Net 0 04-06-2004 02:13 AM
Re: now desparate! - 1st listbox contents disappears when 2nd listbox appears? blenderdude ASP .Net 0 08-03-2003 10:18 PM



Advertisments