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

[Solved] Grid in AJAX Panel

5 Answers 218 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Donald Miller
Top achievements
Rank 1
Donald Miller asked on 03 Jun 2008, 02:26 PM
I have a grid with templated columns inside an AJAX panel. This column has a computed value. This causes a run-time error stating that the controls can not be modified because there is a code block within the controls collection. If I take the grid out of the panel it works fine but I only want to update the grid though. How do I get around this or fix it? Here is my column and it is in a grid contained in a standard AJAX panel.

                    <telerik:GridTemplateColumn UniqueName="DateLocked" Groupable="false" DataField="DateLocked" SortExpression="DateLocked" HeaderText="Date Locked"
                        <ItemTemplate> 
                            <asp:Label Text='<%# (Convert.ToDateTime(DataBinder.Eval(Container.DataItem, "DateLocked")) > DateTime.MinValue.AddYears(1))? DataBinder.Eval(Container.DataItem, "DateLocked") : "N/A" %>' ID="DateLockedLabel" runat="server"></asp:Label> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
 


Associated with this error is the fact that the AJAX manager configuration screen does not list the controls on the page so that I can set the properties to let the update panel handle the AJAX calls for the grid.

5 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 04 Jun 2008, 06:49 AM
Hello Donald Miller,

Do you get the same error as described here? If so, please wrap the label within RadCodeBlock control to resolve the error.

As to the RadAjaxManager issue, you may experience the problem described in this blog post, which appears to be resolved with the latest Beta of Visual Studio 2008 SP1. You can find more info here as well.

Greetings,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Donald Miller
Top achievements
Rank 1
answered on 05 Jun 2008, 03:55 PM
I went and checked out those posts and when I add the RadCodeBlock I get exactly the same error.

The code:
                        <telerik:GridTemplateColumn UniqueName="DateLocked" Groupable="false" DataField="DateLocked" SortExpression="DateLocked" HeaderText="Date Locked"
                            <ItemTemplate> 
                                <telerik:RadCodeBlock ID="RadCodeBlock2" runat="server"
                                    <asp:Label Text='<%# (Convert.ToDateTime(DataBinder.Eval(Container.DataItem, "DateLocked")) > DateTime.MinValue.AddYears(1))? DataBinder.Eval(Container.DataItem, "DateLocked") : "N/A" %>' ID="DateLockedLabel" runat="server"></asp:Label> 
                                </telerik:RadCodeBlock> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn> 

The error:

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).


0
Donald Miller
Top achievements
Rank 1
answered on 05 Jun 2008, 05:35 PM
OK, it isn't really the RadScriptBlock that breaks the page it is the addition of the RadAjaxManager. In either scenario I feel this is a bug in the controls. Basically if I want AJAX in my page I have to do all my formatting server side.
0
Konstantin Petkov
Telerik team
answered on 06 Jun 2008, 07:44 AM
Hi Donald Miller,

The error states there are server-side code blocks on the page, which should be wrapped inside RadCodeBlock to resolve the error. Have you review the entire page along with the Java Script if there are any other server-side code blocks?

Greetings,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
sotero
Top achievements
Rank 1
answered on 24 Jul 2009, 04:47 AM
I had the same problem. I tried to wrap a radgrid inside an Ajax Panel and got this error. The problem was a javascript code with a reference to a server side control.
As Konstantin suggested, I wrapped my javascript code within RadCodeBlock and the problem was solved.
Thanks Suppor!
Tags
Ajax
Asked by
Donald Miller
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Donald Miller
Top achievements
Rank 1
sotero
Top achievements
Rank 1
Share this question
or