如何访问vb.net中RadioButtonList中的单选按钮



我想在填充RadioButtonList时更改RadioButtonList的CssClass。我不知道如何在绑定列表时访问单选按钮。我需要使用DataBind还是DataBounding事件?如何?

使用DataBound事件,因为所有单选按钮都将被填充。

Private Sub YourRadioButtonList_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles YourRadioButtonList.DataBound
    For Each rd As RadioButton In YourRadioButtonList.Items
        'Or some other condition that determines the CSS Class.
        If rd.Checked Then
            rd.CssClass = "NewCssClass"
        End If
    Next
End Sub 

最新更新