in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Export only exports the Headers! No Data!

Last post 9/4/2007 9:14 AM by Mehul Harry (Developer Express). 3 replies.
Page 1 of 1 (4 items)
Sort Posts:
Previous Next
  • 8/30/2007 3:47 PM

    Export only exports the Headers! No Data!

    I have an ASPxGridView and GridView.Exportor on a form.  When I call gridExporter.WriteXlsToResponse() OR gridExporter.WritePdfToResponse(); OR

    gridExporter.WriteRtfToResponse();

     The only thing that gets Exported is the Column Headers.  No Data.

     Here is the aspx Souce

    <%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ProjectStats.aspx.cs" Inherits="FtrTrackerWebApp.ProjectStats" Title="Project Stats Page" %>

    <%

    @ Register Assembly="DevExpress.Web.ASPxGridView.v7.2.Export, Version=7.2.3.0, Culture=neutral, PublicKeyToken=9b171c9fd64da1d1"Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgv" %>

    <%

    @ Register Assembly="DevExpress.Web.ASPxGridView.v7.2, Version=7.2.3.0, Culture=neutral, PublicKeyToken=9b171c9fd64da1d1"Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>

    <%

    @ Register Assembly="DevExpress.Web.ASPxEditors.v7.2, Version=7.2.3.0, Culture=neutral, PublicKeyToken=9b171c9fd64da1d1"Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>

    <%

    @ Register Assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" Namespace="SD.LLBLGen.Pro.ORMSupportClasses"TagPrefix="llblgenpro" %>

     

     

    <

    asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;

    <llblgenpro:LLBLGenProDataSource2 ID="dataSource_Projects" runat="server" AdapterTypeName="FTR.DAL.DatabaseSpecific.DataAccessAdapter, FTR.DALDBSpecific" DataContainerType="EntityCollection" EntityFactoryTypeName="FTR.DAL.FactoryClasses.ProjectEntityFactory, FTR.DAL">

    </llblgenpro:LLBLGenProDataSource2>

    <dxe:ASPxComboBox ID="cboProjects" runat="server" CssFilePath="~/App_Themes/Plastic Blue/Editors/styles.css"

    CssPostfix="PlasticBlue" DataSourceID="dataSource_Projects" ImageFolder="~/App_Themes/Plastic Blue/{0}/" Width="263px" AutoPostBack="True" OnSelectedIndexChanged="cboProjects_SelectedIndexChanged" TextField="Name" ValueField="ProjectId">

    <ValidationSettings>

    <ErrorFrameStyle ImageSpacing="4px">

    <ErrorTextPaddings PaddingLeft="4px" />

    </ErrorFrameStyle>

    <ErrorImage Height="14px" Url="~/App_Themes/Plastic Blue/Editors/edtError.png" Width="14px" />

    </ValidationSettings>

    </dxe:ASPxComboBox>

    <dxwgv:ASPxGridView ID="gridEvms" runat="server" CssFilePath="~/App_Themes/Plastic Blue/GridView/styles.css"

    CssPostfix="PlasticBlue" >

    <Images ImageFolder="~/App_Themes/Plastic Blue/{0}/">

    <HeaderSortDown Height="11px" Url="~/App_Themes/Plastic Blue/GridView/gvHeaderSortDown.png"

    Width="11px" />

    <ExpandedButton Height="9px" Url="~/App_Themes/Plastic Blue/GridView/gvExpandedButton.png"

    Width="9px" />

    <CollapsedButton Height="9px" Url="~/App_Themes/Plastic Blue/GridView/gvCollapsedButton.png"

    Width="9px" />

    <HeaderSortUp Height="11px" Url="~/App_Themes/Plastic Blue/GridView/gvHeaderSortUp.png"

    Width="11px" />

    </Images>

    <Styles CssFilePath="~/App_Themes/Plastic Blue/GridView/styles.css" CssPostfix="PlasticBlue">

    <Header ImageSpacing="10px" SortingImageSpacing="10px">

    </Header>

    </Styles>

    <SettingsPager ShowDefaultImages="False" Visible="False">

    <AllButton Text="All">

    </AllButton>

    <NextPageButton Text="Next &gt;">

    </NextPageButton>

    <PrevPageButton Text="&lt; Prev">

    </PrevPageButton>

    </SettingsPager>

    </dxwgv:ASPxGridView>

    <dxwgv:ASPxGridViewExporter ID="gridExporter" runat="server"

    GridViewID="gridEvms">

    </dxwgv:ASPxGridViewExporter>

    <asp:Button ID="btnExcelExport" runat="server" OnClick="btnExcelExport_Click" Text="Export To Excel" /><asp:Button

    ID="btnPDFExport" runat="server" OnClick="btnPDFExport_Click" Text="Export To PDF" /><asp:Button

    ID="btnRTFExport" runat="server" OnClick="btnRTFExport_Click" Text="Export To RTF" /><br />

    <dxe:ASPxLabel ID="lblError" runat="server" CssFilePath="~/App_Themes/Plastic Blue/{0}/styles.css"

    CssPostfix="PlasticBlue" Text="ASPxLabel" Visible="False"></dxe:ASPxLabel>

    </

    asp:Content>

     

     

    Here is the Code Behind

     

    using

    System;

    using

    System.Data;

    using

    System.Configuration;

    using

    System.Collections;

    using

    System.Web;

    using

    System.Web.Security;

    using

    System.Web.UI;

    using

    System.Web.UI.WebControls;

    using

    System.Web.UI.WebControls.WebParts;

    using

    System.Web.UI.HtmlControls;

    using

    FTR.DataManagers;namespace FtrTrackerWebApp

    {

    public partial class ProjectStats : System.Web.UI.Page

    {

    protected void Page_Load(object sender, EventArgs e)

    {

    if (!Page.IsPostBack)

    {

    BindProjects( );

    this.btnExcelExport.Visible = false;

    this.btnPDFExport.Visible = false; this.btnRTFExport.Visible = false;

    }

     

    }

    private void BindProjects( )

    {

    this.dataSource_Projects.EntityCollection = ProjectManager.GetProjects(true);

    }

    protected void cboProjects_SelectedIndexChanged(object sender, EventArgs e)

    {

    int projectId =0;if (cboProjects.SelectedIndex > -1)

    {

    projectId =
    Int32.Parse(cboProjects.SelectedItem.Value.ToString());

    BindEVMSData(projectId);

    }

    }

    private void BindEVMSData(int projectId)

    {

    this.gridEvms.DataSource = ReportDataManager.GetProjectTotals(projectId);

    this.gridEvms.DataBind(); this.btnExcelExport.Visible = true;

    this.btnPDFExport.Visible = true;this.btnRTFExport.Visible = true;

    }

    protected void btnExcelExport_Click(object sender, EventArgs e)

    {

    this.gridExporter.WriteXlsToResponse();

    }

    protected void btnPDFExport_Click(object sender, EventArgs e)

    {

    this.gridExporter.WritePdfToResponse();

    }

    protected void btnRTFExport_Click(object sender, EventArgs e)

    {

    this.gridExporter.WriteRtfToResponse();

    }

     

     

    }

    }

    Filed under: ,
  • 8/31/2007 2:21 AM In reply to

    Re: Export only exports the Headers! No Data!

    Hi Chris,

    Since this page is bound on the server-side, and the ASPxGridViewExporter generates a postback, the ASPxGridView is not bound and therefore you only see the column headers:

    protected void Page_Load(object sender, EventArgs e)
    {
       if (!Page.IsPostBack)
       {
          BindProjects( );
          this.btnExcelExport.Visible = false;
          this.btnPDFExport.Visible = false; this.btnRTFExport.Visible = false;
       }
    }

    You should consider moving the BindProjects() method outside the IsPostBack() section. Take a look at this tutorial that uses a similar approach:

    Runtime grid binding to a DataTable

    Thanks. 

  • 8/31/2007 1:35 PM In reply to

    Re: Export only exports the Headers! No Data!

    Mehul  ,

     That does not fix the problem.  I removed the whole IsPostback block wrapper, but the issue is with the grid data not the combo box.  The BindProjects() method gets a list of projects from the db and binds them to a combobox.  Upon selecting a project in the combo box (With Auto Postback) the associated data for the project is loaded into the grid and the export buttons are shown.  This gets called without checking the postback status.  Upon clicking one of the expot buttons, the appropriate code is called and the export does take place (with a grid FULL of data).  I can either save or open the exported file either way all I get is the column headers.  NO DATA.

     Any other suggestions?


    Chris



     

  • 9/4/2007 9:14 AM In reply to

    Re: Export only exports the Headers! No Data!

    Hi Chris,

    It seems as if the Grid is not being bound when the exporter is called. You can use the Page.Render method to find if the grid's datasource has any data in it. Without seeing the project it's difficult to figure out the issue. I recommend uploading your project to the support center.

    Check also that the ProjectID is set when the exporter is called. Since the grid doesn't bind if the cboProjects.SelectedIndex is not set. Set a base projectid value and see if that works. If so, then the ASPxComboBox value is not being persisted and you might consider storing the last selectedindex value somewhere, (maybe a session variable). So when the exporter is called it can easily bind to the grid and export the data to your desired format.

    If you're still having problems then please send your project to the support department so they can get to the bottom of this issue.

    Thanks. 

Page 1 of 1 (4 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED