Click here to Skip to main content
15,907,396 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
if (RadioButtonList1.SelectedItem.Text == "Quantity Less than minimum")
       {         


       }


i am using if loop with condition above and am finding null reference exception was unhandled by user code, how to sort it out?
Posted
Updated 5-Dec-11 23:07pm
v2
Comments
Karthik Harve 6-Dec-11 5:09am    
does any item in the radio button list is selected before the statement is executed..???

Use the following :
C#
if (RadioButtonList1.SelectedItem !=null && RadioButtonList1.SelectedItem.Text == "Quantity Less than minimum")
 
Share this answer
 
Comments
Wendelius 6-Dec-11 5:09am    
Clean and efficient, my 5
Mehdi Gholam 6-Dec-11 5:18am    
Cheers, glad you are back!
Wendelius 6-Dec-11 5:30am    
Thanks, since it's our national holiday, I happen to have some extra time :)

http://www.yle.fi/uutiset/news/2011/12/google_honours_finlands_independence_day_3083189.html[^]
Mehdi Gholam 6-Dec-11 5:40am    
Happy national day!
Wendelius 6-Dec-11 5:43am    
Thanks :)
C#
if (!string.IsNullOrEmpty(RadioButtonList1.SelectedItem.Text))
        {
if (RadioButtonList1.SelectedItem.Text == "Quantity Less than minimum")
       {         
 

       }
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900