listbox and selected item's value

Results 1 to 2 of 2

Thread: listbox and selected item's value

  1. #1
    Join Date
    Dec 1969

    Default listbox and selected item's value

    OK. This used to be so easy in asp/vb but not in I can&#039;t figure out how to do retrieve the list box seletectItem&#039;s text. I have list box and with bunch of values<BR><BR>lstFileList.Items.Add("C:Program Files ext1.txt")<BR>lstFileList.Items.Add("C:Program Files ext2.txt")<BR>lstFileList.Items.Add("C:Program Files ext3.txt")<BR><BR>and user can select only one item at any given time. Let&#039;s say he selected item 2 (C:Program Files ext2.txt) and I have the following code to retrieve the text of the selected item<BR><BR>foreach(object selectedItem in this.lstFileList.SelectedItems){ <BR> string sPath = selectedItem.ToString(); <BR>}<BR><BR>and sPath has this value<BR><BR>@"ListViewItem: {C:Program Files ext2.txt}"<BR><BR>How can I just get the path and not the other stuff? Please help me.<BR><BR>Thanks,<BR><BR>-Ramaa<BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: listbox and selected item's value

    Isn&#039;t it<BR><BR>sPath = selectedItem.Text

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts