New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Single RadioButton check at a time with row selection


Product Telerik WebForms Grid for ASP.NET AJAX


This sample represents a symbiosis of radio check and row selection by means of a radio button residing in item template of RadGrid template column


Steps to be followed:

  1. Call the function setGrdRadioButtonOnClick() in the Page_Load to find each radio button in the Grid items.
  2. Add OnClick attribute to the radio button to invoke the javascript function SelectMeOnly which will select only one button at a time.
  3. Select the row which corresponds to the checked radio button in the RadioButton's CheckedChanged event handler.
<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None"
            OnNeedDataSource="RadGrid1_NeedDataSource" Skin="Glassy" EnableAJAX="True" Width="668px">
                    <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Select ">
                            &nbsp;<asp:RadioButton ID="rdSelect" runat="server"   AutoPostBack="True" OnCheckedChanged="rdSelect_CheckedChanged" />
                <ExpandCollapseColumn Visible="False">
                    <HeaderStyle Width="19px" />
                <RowIndicatorColumn Visible="False">
                    <HeaderStyle Width="20px" />
                <Selecting AllowRowSelect="True" />
function SelectMeOnly(objRadioButton, grdName) {
    var i, obj;
    for (i = 0; i < document.all.length; i++) {
        obj = document.all(i);

        if (obj.type == "radio") {
            if (, grdName.length) == grdName) {
                if ( == {
                    obj.checked = true;
                else {
                    obj.checked = false;
public static DataTable dtTable;

protected void Page_Load(object sender, EventArgs e)
    //Function to select one Radio Button at a time 

protected void RadGrid1_NeedDataSource(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e)
    //Populate the Radgrid  
    OleDbConnection MyOleDbConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~//App_Data//NWind.mdb"));
    //the database in the web application root   

    OleDbDataAdapter MyOleDbDataAdapter = new OleDbDataAdapter();

    dtTable = new DataTable();


        string query = "SELECT CategoryID,CategoryName FROM Categories";
        MyOleDbDataAdapter.SelectCommand = new OleDbCommand(query, MyOleDbConnection);

        RadGrid1.DataSource = dtTable;

public void setGrdRadioButtonOnClick()
    int i;
    RadioButton radioButton;
    for (i = 0; i < RadGrid1.Items.Count; i++)
        radioButton = (RadioButton)RadGrid1.Items[i].FindControl("rdSelect");
        radioButton.Attributes.Add("OnClick", "SelectMeOnly(" + radioButton.ClientID + ", " + "'RadGrid1'" + ")");

protected void rdSelect_CheckedChanged(object sender, EventArgs e)
    ((sender as RadioButton).Parent.Parent as GridItem).Selected = (sender as RadioButton).Checked;
'Declare a global DataTable dtTable    
Public Shared dtTable As DataTable

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
    'Function to select one Radio Button at a time    
End Sub

Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs)
    'Populate the Radgrid     
    Dim MyOleDbConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~//App_Data//NWind.mdb"))
    'the database in the web application root      

    Dim MyOleDbDataAdapter As New OleDbDataAdapter()

    dtTable = New DataTable()

        Dim query As String = "SELECT CategoryID,CategoryName FROM Categories"
        MyOleDbDataAdapter.SelectCommand = New OleDbCommand(query, MyOleDbConnection)

        RadGrid1.DataSource = dtTable
    End Try
End Sub

Public Sub setGrdRadioButtonOnClick()
    Dim i As Integer
    Dim radioButton As RadioButton
    i = 0
    While i < RadGrid1.Items.Count

        radioButton = CType(RadGrid1.Items(i).FindControl("rdSelect"), RadioButton)

        radioButton.Attributes.Add("OnClick", "SelectMeOnly(" & radioButton.ClientID & ", " & "'RadGrid1'" & ")")

    End While
End Sub

Protected Sub rdSelect_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
    CType(CType(sender, RadioButton).Parent.Parent, GridItem).Selected = CType(sender, RadioButton).Checked
End Sub

Download the sample

In this article