I have a detailview, inside the detailview there are four radio button and I want to return a value when the radio button is selected. Do my code have any problem?
For Each dtv As DetailsViewRow In questionDetails.Rows
If (CType(dtv.FindControl("Option1"), RadioButton)).Checked = True Then
Label1.Text = "1"
ElseIf (CType(dtv.FindControl("Option2"), RadioButton)).Checked = True Then
Label1.Text = "2"
ElseIf (CType(dtv.FindControl("Option3"), RadioButton)).Checked = True Then
Label1.Text = "3"
ElseIf (CType(dtv.FindControl("Option4"), RadioButton)).Checked = True Then
Label1.Text = "4"
End If
Next dtv
When I run this code it give me this error :
"Object reference not set to an instance of an object."