I have a radbutton in a CommandItemTemplate and I want to be able to set it invisible. I am going to use Active Directory to do a check to see who is using the application and hide the button for basic users. But right now I am just trying to hide the button in the PreRender sub. I am getting an error 'Index was outside the bounds of the array' error.
<div class="divColumn100">
<asp:Button ID="HiddenButton" runat="server" Text="HiddenButton" OnClientClick="HiddenButton_Click" Style="display: none;" />
<telerik:RadToggleButton ID="btnToggleActiveInactive" runat="server" Width="96%" AutoPostBack="true">
<ToggleStates>
<telerik:ButtonToggleState Text="Active Drivers" Selected="true" />
<telerik:ButtonToggleState Text="In-Active Drivers" />
<telerik:ButtonToggleState Text="Both Active and In-Active
Drivers" />
</ToggleStates>
</telerik:RadToggleButton>
</div>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server" IsSticky="true" InitialDelayTime="1000">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default"></telerik:RadAjaxLoadingPanel>
<telerik:RadWindowManager ID="rdwinDrivers" runat="server"></telerik:RadWindowManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel2"EnablePageHeadUpdate="False" UpdatePanelsRenderMode="Inline">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="HiddenButton">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="rdgrdDrivers" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="Panel1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="rdgrdBirthDaysMonthly"/>
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="rfltMenu">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="rdgrdDrivers" UpdatePanelCssClass="" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="rghcMenu">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="rdgrdDrivers" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<div id="demo" class="demo-container
no-bg">
<telerik:RadGrid ID="rdgrdDrivers" runat="server" Skin="Office2010Blue" AutoGenerateColumns="False" AllowPaging="True" PageSize="14" DataSourceID="dsDrivers"
AllowSorting="True" AllowAutomaticUpdates="True" ShowStatusBar="true" AllowFilteringByColumn="true">
<GroupingSettings CaseSensitive="false" />
<SelectedItemStyle CssClass="MySelectedClass" />
<MasterTableView DataSourceID="dsDrivers" CommandItemDisplay="Top" DataKeyNames="EMP_ID" EditFormSettings-PopUpSettings-KeepInScreenBounds="true" EditMode="PopUp">
<CommandItemTemplate>
<telerik:RadButton ID="btnAddEmp" runat="server" Text="Add New
Employee" CommandName="InitInsert"></telerik:RadButton>
</CommandItemTemplate>
<AlternatingItemStyle CssClass="MyRowClass" />
<EditFormSettings EditFormType="Template">
</EditFormSettings>
<Columns>
I have this is the PreRender to set the button visible=False.
Private Sub EmployeeInformation_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender
Dim commandItem As GridCommandItem = CType(rdgrdDrivers.MasterTableView.GetItems(GridItemType.CommandItem)(0),
GridCommandItem)
Dim btn As Button = CType(commandItem.FindControl("btnAddEmp"), Button)
btn.Visible = False
End Sub