How do i expose the contents of a list item?

g_r_a_robinson

Regular
Joined
Jan 13, 2004
Messages
71
I have a listitem that contains a userID for value and userName for text. I am able to iterate through my listitems but I need to find know how to get the text of the listitem where the value = a certain userID.

Here what I mean, this part fill my listboxs like so

<code>
if (DualSelectListBox1.SelectedListBox.Items != null)
{
for (int i = 0; i <= DualSelectListBox1.SelectedListBox.Items.Count -1; i++)
{
item = DualSelectListBox1.SelectedListBox.Items;
assignedUserID = Int32.Parse(item.Value);

</code>

and here I need to check if an item has been removed:

<code>

foreach (int s in UserData.USERidList)
{
int teste = s;

if (! arraylist.Contains(s))
{
String myvalue = item.Text;
String tester = "sf";

}
}

</code>

And it works up until 'String myvalue = item.Text;' . Its here I need to get the text value of the item thats within this if statement that correlates with the item id.
 
do you mean something like this??

C#:
String myvalue;
foreach(ListItem li in ListBox1.Items)
{
  if(li.Selected == true)
   {
     myvalue = li.text;
   }
}
 
Back
Top