sgray128 4/16/2012 8:36:09 PM

Telerik - Hide the Edit button in a RadGrid

Web controls take so much longer to get working, it really helps to have code examples...

This example shows how to hide the edit button in a RadGrid that has 'in place' editing



<telerik:GridEditCommandColumn  UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn>

Private Sub RadGrid4_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles RadGrid4.ItemDataBound
    If TypeOf (e.Item) Is GridDataItem Then
        'access to the data
        Dim oRow As DataRowView = CType(e.Item.DataItem, DataRowView)
        Dim decRemainingQty As Decimal = oRow("RemainingQty")
        If decRemainingQty = 0 Then
            'this will hide the entire column
            RadGrid4.MasterTableView.GetColumn("EditCommandColumn").Display = False
            'this will hide a specific row
            Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
            TryCast(item("EditCommandColumn").Controls(0), LinkButton).Style.Add("Display", "none")
        End If
    End If
End Sub