TelerikDeveloper.com

TelerikDeveloper.com

sgray128 9/16/2015 3:10:39 PM

ASP.NET GridButtonColumn

This article contains code examples for using the Telerik Radgrid GridButtonColumn



 Grid Button functionality, using the ItemDataBound to set the images

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" Width="900px" CssClass="grid" >
    <MasterTableView DataKeyNames="lnitmseq"  >
        <Columns>
            <telerik:GridButtonColumn ButtonType="ImageButton" HeaderText="On Truck" CommandName="OnTruck" UniqueName="OnTruck"></telerik:GridButtonColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

 

Private Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
 
 
    If TypeOf e.Item Is GridDataItem Then
        Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
        Dim bOnTruck As Boolean = RadGrid1.MasterTableView.DataKeyValues(e.Item.ItemIndex)("OnTruck")
 
        If bOnTruck Then
            CType(dataItem("OnTruck").Controls(0), ImageButton).ImageUrl = "~/images/OnTruck1.png"
        Else
            CType(dataItem("OnTruck").Controls(0), ImageButton).ImageUrl = "~/images/OnTruck2.png"
        End If
    End If
End Sub