HOW TO ACCESS RADIOBUTTON IN RADIOBUTTONLIST

john rob

Total Post:108

Points:756
Posted by  john rob
VB.Net 
 1389  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. Sumit Kesarwani

    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

Answer

NEWSLETTER

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