GridButtonColumn LinkButton

This article contains sample code for the Telerik ASP.NET GridButtonColumn when used in LinkButton mode. The resulting column looks like this:

ASP.NET:

<telerik:RadGrid ID="RadGrid1" runat="server" Skin="Bootstrap" AutoGenerateColumns="false"  >
    <MasterTableView DataKeyNames="VendorID" ShowFooter="false" ShowHeader="false"              >
        <Columns>
            <telerik:GridButtonColumn ButtonType="LinkButton" HeaderText ="Vendor" DataTextField ="VENDNAME" UniqueName="VENDNAME"  ></telerik:GridButtonColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Code Behind:

Private Sub RadGrid1_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
    RadGrid1.DataSource = SPs.fp_PM00200_SEL_forLookup("MASONS", App.ConnectionString).getTable
End Sub
Private Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemDataBound
    If TypeOf e.Item Is Telerik.Web.UI.GridDataItem Then
        'access to the data
        Dim oRow As DataRowView = CType(e.Item.DataItem, DataRowView)
 
        'access to the grid control
        Dim oItem As GridDataItem = DirectCast(e.Item, GridDataItem)
 
        Dim dtExpired As Date = oRow("CertExpired")
        If dtExpired < Now Then
            'turn the vendor name red
            oItem("VENDNAME").ForeColor = System.Drawing.Color.Red
        End If
    End If
 
End Sub
Private Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles RadGrid1.ItemCommand
    If TypeOf e.Item Is GridDataItem Then
        'get the vendor
        Dim strVendorID As String = RadGrid1.MasterTableView.DataKeyValues(e.Item.ItemIndex)("VendorID")
 
        'code that does work here.
    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