GridTemplateColumn - Checkbox

This article will demonstrate the use of a RadCheckBox control in a RadGrid GridTemplateColumn to allow selecting and deselecting grid rows.

What makes this different is that you can check any of the rows without unlocking the row

Grid Markup. Note that the checkbox has AutoPostBack set to TRUE.

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" Width="400px" CssClass="grid" >
    <MasterTableView DataKeyNames="DashboardID" >
        <Columns>
            <telerik:GridTemplateColumn HeaderStyle-Width="50px">
                <ItemTemplate>
                    <telerik:RadCheckBox ID="chkSelected" Skin="Bootstrap" runat="server" AutoPostBack="true" CommandName="Selected" Checked='<%# DataBinder.Eval(Container.DataItem, "Selected", "")%>'></telerik:RadCheckBox>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="dashboardDesc" HeaderText="Dashboard" ReadOnly="true"></telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

 

Code Behind

Private Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles RadGrid1.ItemCommand
 
    If TypeOf e.Item Is GridDataItem Then
        If e.CommandName = "Selected" Then
            Dim strDashboardID As String = RadGrid1.MasterTableView.DataKeyValues(e.Item.ItemIndex)("DashboardID")
            Dim chkSelected As RadCheckBox = CType(e.Item.FindControl("chkSelected"), RadCheckBox)
            Dim bSelected As Boolean = chkSelected.Checked
 
            SPs.sp_4P_UserDashboard_MERGE(CInt(Session("editedUserID")), strDashboardID, bSelected, App.ConnectionString).execute()
        End If
    End If
End Sub

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences