I have a screen with a few grids on it. Here is a copy of one of those grid
at run time I need to change the way the grid works according to Page.User.IsInRole
if the user is not in the correct role I want to display the grid but reomve the edit, delete, and add ne functionality.
I tried
but the grid still had the functionality. is there anyway to do this?
| <telerik:RadPageView ID="pvRegistration" runat="server"> |
| <telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server"> |
| <telerik:RadGrid ID="rgRegistration" runat="server" GridLines="None" AllowSorting="True" |
| AllowPaging="true" PageSize="10" AllowMultiRowEdit="false" AutoGenerateColumns="False" |
| ShowStatusBar="true" OnNeedDataSource="Registration_NeedDataSource" OnItemDataBound="Registration_ItemDataBound" |
| OnUpdateCommand="RegistrationGrid_UpdateCommand" OnInsertCommand="RegistrationGrid_InsertCommand" |
| OnDeleteCommand="RegistrationGrid_DeleteCommand" |
| Skin="Office2007" Width="100%" > |
| <MasterTableView CommandItemDisplay="Top" DataKeyNames="RepFirmID" EditMode="InPlace"> |
| <Columns> |
| <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"> |
| <HeaderStyle Width="50px" /> |
| </telerik:GridEditCommandColumn> |
| <telerik:GridTemplateColumn HeaderText="Firm Type" SortExpression="FirmTypeDescription" |
| UniqueName="FirmType"> |
| <ItemTemplate> |
| <asp:Label ID="lbFirmType" runat="server" Text='<%# Eval("FirmTypeDescription")%>' /> |
| </ItemTemplate> |
| <EditItemTemplate> |
| <telerik:RadComboBox ID="rcbFirmType" DataTextField="FirmTypeDescription" DataValueField="FirmTypeID" |
| runat="server" Width="300px" /> |
| <asp:RequiredFieldValidator ControlToValidate="rcbFirmType" ErrorMessage="*" InitialValue="Select Type" |
| runat="server" ToolTip="Type is Required" FontColor="Red" /> |
| <asp:Label runat="server" ID="lbFirmTypeID" Visible="false" Text='<%# Eval("FirmTypeID") %>'></asp:Label></EditItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridButtonColumn ConfirmText="Remove this Firm?" ConfirmDialogType="RadWindow" |
| CommandName="Delete" ConfirmTitle="Delete" Text="Delete" ShowInEditForm="false"> |
| <HeaderStyle Width="25px" /> |
| </telerik:GridButtonColumn> |
| </Columns> |
| <EditFormSettings> |
| <EditColumn ButtonType="ImageButton" InsertText="Insert" UpdateText="Update" UniqueName="EditCommandColumn1" |
| CancelText="Cancel"> |
| </EditColumn> |
| <FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle> |
| </EditFormSettings> |
| <PagerStyle Mode="NumericPages"></PagerStyle> |
| </MasterTableView> |
| </telerik:RadGrid> |
| <button onclick="ShowForm('FirmType'); return false;"> |
| Edit Type</button> |
| </telerik:RadAjaxPanel> |
| </telerik:RadPageView> |
at run time I need to change the way the grid works according to Page.User.IsInRole
if the user is not in the correct role I want to display the grid but reomve the edit, delete, and add ne functionality.
I tried
| protected void Registration_PreRender(object sender, EventArgs e) |
| { |
| if (!Page.User.IsInRole("COMPLIANCE USER")) |
| { |
| rgRegistration.AllowAutomaticInserts = false; |
| rgRegistration.AllowAutomaticUpdates = false; |
| rgRegistration.AllowAutomaticDeletes = false; |
| //rgRegistration.MasterTableView.RenderColumns[3].Display = false; |
| } |
| } |