---
title: "How to access radiobutton in RadioButtonList"  
description: "How to access radiobutton in RadioButtonList"  
author: "Anonymous User"  
published: 2014-09-05  
updated: 2023-07-06  
canonical: https://www.mindstick.com/forum/2252/how-to-access-radiobutton-in-radiobuttonlist  
category: "vb.net"  
tags: ["vb.net"]  
reading_time: 2 minutes  

---

# How to access radiobutton in RadioButtonList

I want to change the [CssClass](https://www.mindstick.com/forum/12787/how-to-get-access-to-cssclass-property-for-server-element-isn-t-webcontrol-in-asp-dot-net) for the [RadioButtonList](https://www.mindstick.com/forum/2150/modify-page_load-method-for-radiobuttonlist) while populating the the RadioButtonList. I don't know how to [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) the [radio button](https://www.mindstick.com/articles/12743/radio-button-in-android) while [binding](https://www.mindstick.com/blog/146/dynamic-binding-in-c-sharp) the list. do I need to use [DataBind](https://www.mindstick.com/forum/2091/javascript-function-on-data-bind) or DataBounding [event](https://www.mindstick.com/articles/167719/marquee-hire-benefits-of-event-lighting-hire-london) ?

## Replies

### Reply by Aryan Kumar

Sure, I can help you with that. Here are the steps on how to access radiobutton in radiobuttonlist:

1. Create a new Windows Forms project in VB.NET.
2. Add a RadioButtonList control to the form.
3. In the code behind file, add the following code:

VB.Net

```plaintext
Private Sub RadioButtonList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RadioButtonList1.SelectedIndexChanged
    ' Get the selected radiobutton.
    Dim radiobutton As RadioButton = RadioButtonList1.SelectedItem

    ' Do something with the radiobutton.
    ' For example, you could print the text of the radiobutton.
    Console.WriteLine(radiobutton.Text)
End Sub
```

1. Run the project. When you select a radiobutton in the RadioButtonList control, the code in the `SelectedIndexChanged` event handler will be executed. The code will get the selected radiobutton and print its text on the console.

Here is an explanation of the code:

- The `SelectedIndexChanged` event is raised when the SelectedIndex property of the RadioButtonList control changes.
- The `SelectedItem` property of the RadioButtonList control returns the selected radiobutton.
- The `Text` property of the RadioButton control returns the text of the radiobutton.

### Reply by Sumit Kesarwani

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    NextEnd Sub
```


---

Original Source: https://www.mindstick.com/forum/2252/how-to-access-radiobutton-in-radiobuttonlist

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
