I have the following RaGrid, which displays the CommanItems "Add New Record" and "Refresh" in the Grid at TopAndBottom:
Under specific curcimstances I'd like to hide the "Add New Record" LinkButton and tried to do that on DataBound:
| <MasterTableView Width="98%" ShowFooter="True" CommandItemDisplay="TopAndBottom"> |
| <CommandItemTemplate> |
| <asp:LinkButton ID="btnAddNewRecord" runat="server" CommandName="AddNewRecord" Style="vertical-align: bottom"> |
| <asp:Image ID="imgAdd" runat="server" ImageUrl="~/App_ThemesCustom/images/AddRecord.gif" /> |
| Add New Record |
| </asp:LinkButton> |
| <asp:LinkButton ID="btnRefresh" runat="server" CommandName="Refresh" Style="vertical-align: bottom"> |
| <asp:Image ID="imgRefresh" runat="server" ImageUrl="~/App_ThemesCustom/images/Refresh.gif" /> Refresh |
| </asp:LinkButton> |
| </CommandItemTemplate> |
Under specific curcimstances I'd like to hide the "Add New Record" LinkButton and tried to do that on DataBound:
| protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if(e.Item is GridCommandItem) |
| { |
| if (!UserHasEditAccess()) |
| { |
| this.ParentPage.FindControlRecursive(this, "btnAddNewRecord").Visible = false; |
| } |
| } |
| } |
This code works to a degree. It hides the "Add New Record" button in the "Top" of the grid, but it is still visible on the "Bottom" of the grid.
Any idea why it's not making it invisible in both the "Top" and the "Bottom"?