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

Error On grid export to excel-ExcelML-URGENT

3 Answers 177 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chandru
Top achievements
Rank 1
Chandru asked on 21 Jun 2011, 04:16 PM
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.

protected void Page_Load(object sender, EventArgs e)
  {
      List<ReportDto> reportlt = BuildReport<ReportDto>();
      ReportGrid.DataSource = reportlt;
      ReportGrid.DataBind();
  }
Code in .ascx is
<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();
       }
   }

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Jun 2011, 01:07 PM
Hello Chand,

ExcelML export works with advanced data-binding only. Please examine the following links:
ExcelML basics
Advanced Data-binding (using NeedDataSource event)

Also when binding to List collection you have to set UseAllDataFields property to true.

Best regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Jeff
Top achievements
Rank 1
answered on 29 May 2019, 03:59 PM
These links aren't working.  Have these documents moved?
0
Vessy
Telerik team
answered on 31 May 2019, 08:10 AM
Hi Jeff,

The structure of our latest documentation is different than the one we had back in 2011, this is why the links above are invalid. You can access the linked resources via the following links:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/exporting/export-formats/excelml-export/excelml-basics.html
and
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-binding/understanding-data-binding/server-side-binding/advanced-data-binding-(using-needdatasource-event)

Regards,
Vessy
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Chandru
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Jeff
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or