Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
240
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
posted

Hi there,

I'm having a difficult time getting the WebHierarchicalDataGrid to work properly.  I've added one to a test page and without any code in the code behind file to bind any data to it, I get this error message:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

I initially had tried binding some items to the collection, then leaving the call to databind out, then finally removing all code from the code behind and I still get this error.  Does anyone know what's causing it?  Code below - it's pulled directly from your samples page.

<ig:WebHierarchicalDataGrid ID="dg" runat="server" AutoGenerateColumns="false" AutoGenerateBands="true" InitialExpandDepth="0" InitialDataBindDepth="-1" Height="450" Width="700px" DataKeyFields="SupplierID">
        <ExpandCollapseAnimation SlideOpenDirection="Auto" SlideOpenDuration="300" SlideCloseDirection="Auto" SlideCloseDuration="300" />
        <Columns>
            <ig:BoundDataField DataFieldName="SupplierID" Key="SupplierID" Header-Text="Supplier ID" />
            <ig:BoundDataField DataFieldName="CompanyName" Key="Company" Header-Text="Company" Width="230px" />
            <ig:BoundDataField DataFieldName="ContactName" Key="Contact" Header-Text="Contact" Width="150px" />
            <ig:BoundDataField DataFieldName="Region" Key="Region" Header-Text="Region" Width="80px" />
        </Columns>
    </ig:WebHierarchicalDataGrid>

Thanks!

Parents
  • 6748
    Suggested Answer
    posted

    Hello Kslone,

     

    Do you have a script tag on the page, in which you are having code blocks (<%= %>)? Would you test if you will continue getting this error if you delete (not just comment) the line?

    If this is the case, you will stop getting this error if you move your script within an element with runat=”server” attribute:

    <div runat="server">

            <script type="text/javascript" language="javascript">

                    

         </script>

    </div>

    Hope this helps.

     

    Regards,

    Lyuba

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

     

     

Reply Children
  • 265
    Offline posted in reply to Stephen

    http://blogs.infragistics.com/forums/p/34316/186308.aspx

    The last entry in the above link seems to be written by the ONE knowledgeable person at Infragistics.

    For us, it turned out we had a reference to <%= Page.ResolveUrl("~/../Common/jquery-1.7.1.min.js") %> in a <script> tag in the <head> section.  Once we moved it out of the <head> and into the <body> wrapped in a <div runat="server"> the error went away.

     

    Crazy stuff.