This is a migrated thread and some comments may be shown as answers.

The Controls collection cannot be modified because the control contains code blocks

1 Answer 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brandon
Top achievements
Rank 1
Brandon asked on 05 Dec 2014, 06:24 PM
Hi I am trying to use the RadGrid and I keep getting the following Error:

The Controls collection cannot be modified because the control contains code blocks

Any help would be much appreciated.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PluginViewAndDownloadBillData.ascx.cs" Inherits="VIPEnergyClientPortal.Plugins.PluginViewAndDownloadBillData" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<telerik:RadScriptManager ID="sm1" runat="server" EnableTheming="True">
    <Scripts>
        <asp:ScriptReference Assembly="Telerik.Web.UI"
            Name="Telerik.Web.UI.Common.Core.js">
        </asp:ScriptReference>
        <asp:ScriptReference Assembly="Telerik.Web.UI"
            Name="Telerik.Web.UI.Common.jQuery.js">
        </asp:ScriptReference>
        <asp:ScriptReference Assembly="Telerik.Web.UI"
            Name="Telerik.Web.UI.Common.jQueryInclude.js">
        </asp:ScriptReference>
    </Scripts>
</telerik:RadScriptManager>

<telerik:RadGrid ID="RadGrid1" runat="server" GroupPanelPosition="Top"
    ResolvedRenderMode="Classic" AllowFilteringByColumn="True"
    DataSourceID="UtilityAccounts">
    <MasterTableView AutoGenerateColumns="False" DataSourceID="UtilityAccounts">
        <Columns>
            <telerik:GridBoundColumn DataField="LocationID"
                DataType="System.Guid"
                FilterControlAltText="Filter LocationID column"
                HeaderText="LocationID" SortExpression="LocationID"
                UniqueName="LocationID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="AccountNumber"
                FilterControlAltText="Filter AccountNumber column"
                HeaderText="AccountNumber"
                SortExpression="AccountNumber"
                UniqueName="AccountNumber">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Utility"
                FilterControlAltText="Filter Utility column"
                HeaderText="Utility"
                SortExpression="Utility"
                UniqueName="Utility">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Commodities"
                FilterControlAltText="Filter Commodities column"
                HeaderText="Commodities"
                SortExpression="Commodities"
                UniqueName="Commodities" ReadOnly="True">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

<asp:ObjectDataSource ID="UtilityAccounts" runat="server"
    SelectMethod="UtilityAccountData"
    TypeName="VIPEnergyClientPortal.Plugins.PluginViewAndDownloadBillData">
    <SelectParameters>
        <asp:ControlParameter ControlID="txtAccountNumber" DbType="Guid"
            Name="LocationID" PropertyName="Text" />
    </SelectParameters>
</asp:ObjectDataSource>

<asp:TextBox ID="txtAccountNumber" runat="server" Visible="false"></asp:TextBox>

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 10 Dec 2014, 11:49 AM
Hi,

The error you are seeing could be observed if there are code blocks used in the client-side scripts. Ensure that the custom JavaScript on the page is wrapped in a RadCodeBlock. Check out the following article that describes the RadCodeBlock in more detail.



Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Brandon
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or