How to access radiobutton in RadioButtonList

Total Post:108

Points:756
VB.Net 
 1757  View(s)
Ratings:
Rate this:

I want to change the CssClass for the RadioButtonList while populating the the RadioButtonList. I don't know how to access the radio button while binding the list. do I need to use DataBind or DataBounding event ? 

  1. Post:378

    Points:2694
    Re: How to access radiobutton in RadioButtonList

    Hi John, 


    Use the DataBound event as then all of the Radio Buttons will be populated.

    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

      Modified On Apr-05-2018 05:50:05 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!