Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
149 views
in Technique[技术] by (71.8m points)

asp.net - Radio button list in vb.net

How can I check if a radio button inside a radio button list is checked?

I used if radiobuttonlist1.selectedindex > -1 and then I checked a radio button, but it is not reading the selected, it is always going to the else statement. this is my code:

Dim rl1 As RadioButtonList = New RadioButtonList()

If rbl1.SelectedIndex > -1

 Label2.Text = "Checked"

Else

 Label2.Text = "Not Checked" 

End If
question from:https://stackoverflow.com/questions/65833174/radio-button-list-in-vb-net

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You declared your var wrong:

Dim rl1 As Radio Button List = New Radio Button List()

should be:

Dim rl1 As RadioButtonList = New RadioButtonList()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...