Hi
I have 2 buttons in .aspx page ,one for pdf export and other for excel export.Pdf works okay.But on excel export, i get error "RegisterRequiresControlState can only be called before and during PreRender. "
I am using dynamically loaded user controls and the grid DataBind() is in the Page_Load of the user control.
The below is the Code in user control. What do I need to do to get rid of this error? I did see the forum answers where it says "Calling Rebind not after PreRender is not supported " .But I am not doing anything on PreRender knowingly.
Code in .ascx is
code in aspx.cs page is:
I have 2 buttons in .aspx page ,one for pdf export and other for excel export.Pdf works okay.But on excel export, i get error "RegisterRequiresControlState can only be called before and during PreRender. "
I am using dynamically loaded user controls and the grid DataBind() is in the Page_Load of the user control.
The below is the Code in user control. What do I need to do to get rid of this error? I did see the forum answers where it says "Calling Rebind not after PreRender is not supported " .But I am not doing anything on PreRender knowingly.
protected void Page_Load(object sender, EventArgs e) { List<ReportDto> reportlt = BuildReport<ReportDto>(); ReportGrid.DataSource = reportlt; ReportGrid.DataBind(); }<telerik:RadGrid runat="server" SkinID="main" style="outline: none;" id="ReportGrid"> <ExportSettings> <Pdf AllowAdd="false" AllowCopy="True" AllowModify="false" AllowPrinting="true" Author="RadTech" Keywords="None" PageBottomMargin=".1in" PageLeftMargin=".1in" PageRightMargin=".1in" PageTopMargin="1in" PaperSize="Letter" PageHeight="8.5in" PageWidth="11.69in" Title="Client QA -Case Report" /> <Excel Format="ExcelML" /> </ExportSettings> <MasterTableView> <NoRecordsTemplate> There are no records to display </NoRecordsTemplate> <Columns> .... .... ... </Columns> </MasterTableView> </telerik:RadGrid>code in aspx.cs page is:
protected void BtnExportToExcel_Click(object sender,EventArgs e) { try { TrySearch(); }
catch
{
} UserControl usr = new UserControl(); usr = ReportHolder.FindControl("CaseReport") as UserControl; if (usr != null) { RadGrid grdExcel = usr.FindControl("ReportGrid") as RadGrid; grdExcel.ExportSettings.OpenInNewWindow = true; grdExcel.ExportSettings.ExportOnlyData = true; grdExcel.ExportSettings.IgnorePaging = true; grdExcel.MasterTableView.ExportToExcel(); } }