I am trying to hide a commandItem link button based on a hiddenfiled that is in a template column inside the grid. It keeps giving me a null value because I am assuming the grid head loads beofre the body. So how can I hide a command item from a row in the grid.
<CommandItemTemplate> <asp:LinkButton ID="lnkAddDate" Text="Add Dates" CommandName="InitInsert" runat="server"></asp:LinkButton> </CommandItemTemplate> <Columns> <telerik:GridTemplateColumn> <ItemTemplate> <asp:LinkButton ID="lnkDelDate" runat="server" CommandName="DelDate" CommandArgument='<%# Bind("intLeaseDateId")%>'>Delete</asp:LinkButton> <asp:HiddenField ID="HFOccur" runat="server" Value='<%# Bind("intOcurranceId")%>' /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridEditCommandColumn HeaderText="Edit" UniqueName="EditGrid" /> <telerik:GridBoundColumn HeaderText="Start Date" DataField="dtStartDate" /> <telerik:GridBoundColumn HeaderText="End Date" DataField="dtEndDate" /> </Columns>I can find it here to hide a linkbutton that is a column in the grid, but I cannot get at the commanditem button. If (TypeOf e.Item Is GridDataItem AndAlso e.Item.OwnerTableView.Name = "LeaseDates") Then Dim item As GridDataItem = CType(e.Item, GridDataItem) Dim delete As LinkButton = DirectCast(item.FindControl("lnkDelDate"), LinkButton) Dim occur As HiddenField = DirectCast(item.FindControl("HFOccur"), HiddenField) Dim status As Integer = 2 If Convert.ToInt32(occur.Value) = 5 Then delete.Visible = False End If End IfAtempt at the commanditem from other sources on web, but does not work. Protected Sub myradGrid_ItemCreated(sender As Object, e As GridItemEventArgs) Handles myradGrid.ItemCreated If (TypeOf e.Item Is GridCommandItem AndAlso e.Item.OwnerTableView.Name = "LeaseDates") Then Dim cmdItem As GridCommandItem = CType(e.Item, GridCommandItem) Dim btn As LinkButton = DirectCast(cmdItem.FindControl("lnkAddDate"), LinkButton) 'Dim occur As HiddenField = DirectCast(cmdItem.FindControl("HFOccur"), HiddenField) 'Response.Write(occur.Value) 'Response.End() 'If Convert.ToInt32(occur.Value) = 5 Then ' btn.Visible = False 'End If End If End Sub