I have a LinkButton in a CommandItemTemplate in a RadGrid. I need to set the visibility of this button to false when the user is not authorized to use certain functionality. I do an authorization check in the Page_load method, and set the visibility to false. this works fine. However when the user clicks on one of the column headers(to sort) the button then shows back up. This doesn't happen to two other columns that I also set the visibility on to false. Is there some grid property I need to set to make this work?
ASP.NET:
<
CommandItemTemplate>
<div class="commandItemButtons">
<asp:LinkButton ID="addButton" runat="server" CommandName="InitInsert">
<img class="padding" alt="Add Acronym" src="../App_Themes/Default/TelerikControls/Grid/add.png" />Add Acronym</asp:LinkButton>
</div>
</CommandItemTemplate>
C#:
//Makes a reference to the addButton on the Page
LinkButton addButton = (WebUtilities.FindControl(acronymRadGrid, "addButton") as LinkButton) ;
//Administrators get to see all of the columns as well as the add button
if (WebUtilities.IsAdmin(User)) {
addButton.Visible =
true;
foreach (GridColumn column in acronymRadGrid.Columns) {
column.Visible =
true;
}
}
//Regular users only get to see the Acronym and Description columns
else {
addButton.Visible =
false;
foreach (GridColumn column in acronymRadGrid.Columns) {
if (column.HeaderText != "Acronym" && column.HeaderText != "Description") {
column.Visible =
false;
}
}
}
Thanks,
-Mike