Results 1 to 3 of 3

Thread: Selected Item in Listbox ???

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2002
    Location
    Pakistan
    Posts
    32

    Arrow Selected Item in Listbox ???

    Hello

    I want to check whether any item is selected in the listbox or not .... It's something like if no item is selected in the listbox than i don't want to perform my task. so i need a condition with which i can check whether an item is selected in the listbox ... i thought some property like listbox1.selected = true/false might be available but couldn't find it in aspnet.

    Regards,

    Harris Moin
    You'll get life just for once so don't waste it .......

  2. #2
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375
    If it's a dropdownlist you could query the SelectedIndex property and see if it returns a value greater or equal to 0 (Means that a item is selected)

    Cheers
    MarkusJ

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2002
    Location
    Pakistan
    Posts
    32

    thanx ...

    Thanx ... but i did it a bit different way .... as i was using visual C# ... so i put the code where this null exception was coming in try catch ... it was something like ...

    try
    {
    // code with expected error
    }

    catch( NullReferenceException )

    and it works perfectly fine

    Regards,

    Harris Moin
    You'll get life just for once so don't waste it .......

Posting Permissions

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



Click Here to Expand Forum to Full Width