Hi,
i have a problem using AJAX with the WebDataGrid in a SharePoint 2010 Visual WebPart. The Page will come up without any Problem. But if there is an asynchronous refresh e.g. if using the filter or the paging behavior i will get the following error message:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
My Code (ASPX):
<%@ Register Assembly="Infragistics35.Web.v10.1, Version=10.1.20101.2134, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" TagPrefix="igtbl" Namespace="Infragistics.Web.UI.GridControls" %><%@ Register Assembly="Infragistics35.Web.v10.1, Version=10.1.20101.2134, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" TagPrefix="ig" Namespace="Infragistics.Web.UI.ListControls" %><%@ Register Assembly="Infragistics35.Web.v10.1, Version=10.1.20101.2134, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" TagPrefix="igsch" Namespace="Infragistics.Web.UI.EditorControls" %> <div id="container" runat="server"> <div id="DataGridWrapper"> <igtbl:WebDataGrid ID="WebDataGrid1" runat="server" Height="500px" Width="800px" AutoGenerateColumns="False" EnableAjax="true" EnableViewState="false" EnableDataViewState="false" ClientEvents-AJAXResponse="277A67FD-9934-432E-9D76-BF48862DE8DD"> <Columns> <igtbl:BoundDataField DataFieldName="USER_ID" Key="USER_ID"> <Header Text="CWID" /> </igtbl:BoundDataField> <igtbl:BoundDataField DataFieldName="FULL_NAME" Key="FULL_NAME" Width="150px"> <Header Text="Name" /> </igtbl:BoundDataField> <igtbl:BoundDataField Key="PLANNED_DATE"> <Header Text="Planned Date" /> </igtbl:BoundDataField> </Columns> <Behaviors> <igtbl:Paging PageSize="100" PagerAppearance="Bottom" Enabled="true"/> <igtbl:Filtering Enabled="true" AnimationEnabled="false"/> <igtbl:RowSelectors Enabled="true"/> <igtbl:Selection CellSelectType="Single" RowSelectType="Multiple" ColumnSelectType="Multiple" Enabled="true" /> </Behaviors> </igtbl:WebDataGrid> </div> </div>
Code behind:
protected override void OnInit(EventArgs e) { base.OnInit(e); try {
SPSecurity.RunWithElevatedPrivileges(delegate { UserService userService = new UserService(ServerAndInstance, Database); WebDataGrid1.DataSource = userService.GetTopUsers(); WebDataGrid1.DataBind(); }); } catch (Exception) { throw new ApplicationException(WebDataGrid1.EmptyRowsTemplate.ToString());
} }
WebPartCode:
protected override void CreateChildControls() { UserControl uc = (UserControl)Page.LoadControl(_ascxPath); UserControl.Database = databaseName; UserControl.ServerAndInstance = SQLServer;
Controls.Add(UserControl);
}
For additional information:
I'm using the default SharePoint 2010 Design with the v4.master MasterPage.
Can someboy help?
Did you solve this by any chance? I'm having the exact same error, it works if i disable ajax or if i put the usercontrol right on the page, e.g. in an application page or page layout. However i'd like to have it as a webpart.
no, still no solution for the problem.