Friday, February 12, 2010

Asp.net radiobuttonlist control error?

hi guys, how can i prevent this error message (Object reference not set to an instance of an object.) when trying to read the selecteditem.tostring when it's not selected. It's not a required field but how can i see if there's nothing selected? It does work when i select a valueAsp.net radiobuttonlist control error?
The two posts above have it correct.





if (MyRadioBtn.SelectedIndex %26gt; -1) {


//do your stuff here .. this code executes only if a selectedItem has been set.


}Asp.net radiobuttonlist control error?
You can use the SelectedIndex property. If no items are selected, it will be set to -1
Hi!





Check property ';SelectedIndex'; to know if something is selected. If it's %26gt; -1, than it means something is selected.





Hope this helps!
  • Scooter
  • No comments:

    Post a Comment