Error On grid export to excel-ExcelML-URGENT

4 posts, 0 answers
  1. Chand
    Chand avatar
    3 posts
    Member since:
    Apr 2011

    Posted 21 Jun 2011 Link to this post

    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();
           }
       }
  2. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 24 Jun 2011 Link to this post

    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.

  3. Jeff
    Jeff avatar
    4 posts
    Member since:
    Apr 2019

    Posted 29 May Link to this post

    These links aren't working.  Have these documents moved?
  4. Vessy
    Admin
    Vessy avatar
    2068 posts

    Posted 31 May Link to this post

    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.
Back to Top