ListControl SelectedValue Example
Skip Navigation Links.

ListControl SelectedValue Example

Skip Navigation LinksHome :: ASP.NET :: Controls :: listbox

Here's how to display a selected listitem from a list box

Enter the value of the item to select:
  



Here's the code...


      Sub Button_Click(sender As Object, e As EventArgs)

         ' Perform this operation in a try-catch block in case the item is not found.
         Try
   
            List.SelectedValue = ItemTextBox.Text
            MessageLabel.Text = "You selected " & List.SelectedValue + "."
        
         Catch ex As Exception
     
            List.SelectedValue = Nothing         
            MessageLabel.Text = "Item not found in ListBox control."
     
         End Try
             
      End Sub


Next >> TreeNodeCollection
top of page
all content ©1996/2012 BennySutton.com
all images © their respective owners This site uses Thumbshots previews