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

Multiple issues with Export

4 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lynn
Top achievements
Rank 2
Lynn asked on 08 Dec 2012, 04:38 PM
I am using the Export facilities of the grid straight out of one of your examples and encountering several different problems.  The only option that is working correctly is to export to CSV.

(1) When exporting to Excel, my Excel 2010 is opening and the data is loaded from the grid, but after a few seconds, Excel goes into a loop and I have to kill it from Task Manager.

(2) When exporting to a PDF file, the PDF file never displays but I do receive a new window filled with .net errors.  (see attached screen capture.

(3) When exporting to CSV, everything works fine and the data is opened in an Excel spreadsheet which operates fine (no problem).

(4) When exporting to Word, Work 2010 starts to open then hangs (never even shows in Task Manager) and I have to click on "Cancel" on the splash screen to get out of Word.

I have included the code (both display and code-behind) below.  

The version being used is 2012.3.1016.45; Windows 8 64-bit, VS2012.  SQL Server 2008 R2 Standard.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <script type="text/javascript">
        //Put your JavaScript code here.
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <div>
        <br /><br />
 
         <telerik:RadGrid ID="RadGrid1" AllowSorting="true" runat="server" DataSourceID="SqlDataSource1"
             AutoGenerateColumns="false" Width="100%" Height="250px" >
            <ExportSettings HideStructureColumns="true" IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true">
        </ExportSettings >
 
             
 
            <MasterTableView Width="100%" CommandItemDisplay="Top">
                <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToCsvButton="true" ShowExportToPdfButton="true"></CommandItemSettings>
            </MasterTableView>            
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet" SelectCommand="SELECT * FROM OfcAgent_List WHERE AgentRecType = 'Agent' AND AgentStatus = 'Active' AND Account = 1" SelectCommandType="Text" ConnectionString="Data Source=Lynn-PC;Initial Catalog=BrokerPlus2008_new;user id=sa;password=wheat7211"></asp:SqlDataSource>
        <br /><br />
    </div>
    </form>
</body>
</html>


using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
 
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //http://msdn.microsoft.com/en-us/library/w1kdt8w2(v=vs.90).aspx
 
        if (!Page.IsPostBack)
        {
            //  You can only define the grid columns during page load, do not also do it on postback
            DefineGrid();
        }
 
    }
    private void DefineGrid()
    {
        GridHyperLinkColumn hypercolumn = null;
        GridBoundColumn boundcolumn = null;
 
        hypercolumn = new GridHyperLinkColumn();
        this.RadGrid1.Columns.Add(hypercolumn);
        hypercolumn.HeaderText = "Edit";
        hypercolumn.Text = "<img border=\"0\" alt=\"View\" src=\"../Icons/pencil_16.png\" />";
        hypercolumn.DataNavigateUrlFields = new string[] { "Agent" };
        hypercolumn.DataNavigateUrlFormatString = "Default2.aspx?K=" + "{0}";
        hypercolumn = null;
 
        boundcolumn = new GridBoundColumn();
        this.RadGrid1.Columns.Add(boundcolumn);
        boundcolumn.UniqueName = "CompanyName";
        boundcolumn.DataField = "CompanyName";
        boundcolumn.HeaderText = "Company";
        boundcolumn.Visible = true;
        boundcolumn = null;
 
        boundcolumn = new GridBoundColumn();
        this.RadGrid1.Columns.Add(boundcolumn);
        boundcolumn.UniqueName = "OfficeName";
        boundcolumn.DataField = "OfficeName";
        boundcolumn.HeaderText = "Office";
        boundcolumn.Visible = true;
        boundcolumn = null;
 
        boundcolumn = new GridBoundColumn();
        this.RadGrid1.Columns.Add(boundcolumn);
        boundcolumn.UniqueName = "AgentID";
        boundcolumn.DataField = "AgentID";
        boundcolumn.HeaderText = "ID";
        boundcolumn.Visible = true;
        boundcolumn = null;
 
        boundcolumn = new GridBoundColumn();
        this.RadGrid1.Columns.Add(boundcolumn);
        boundcolumn.UniqueName = "AgentFullName";
        boundcolumn.DataField = "AgentFullName";
        boundcolumn.HeaderText = "Name";
        boundcolumn.Visible = true;
        boundcolumn = null;
 
        boundcolumn = new GridBoundColumn();
        this.RadGrid1.Columns.Add(boundcolumn);
        boundcolumn.UniqueName = "AgentCellular";
        boundcolumn.DataField = "AgentCellular";
        boundcolumn.HeaderText = "Cellular";
        boundcolumn.Visible = true;
        boundcolumn = null;
 
        boundcolumn = new GridBoundColumn();
        this.RadGrid1.Columns.Add(boundcolumn);
        boundcolumn.UniqueName = "AgentEmail";
        boundcolumn.DataField = "AgentEmail";
        boundcolumn.HeaderText = "Email";
        boundcolumn.Visible = true;
        boundcolumn = null;
    }
 
}

4 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 13 Dec 2012, 08:12 AM
Hi Lynn,

I was not able to replicate your issues. I prepared a small sample based on your code and attached it to this forum post. Could you please give it a try and let me know how is differs from your real setup?

Regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Lynn
Top achievements
Rank 2
answered on 13 Dec 2012, 01:43 PM
Kostadin,

Thank you for the time spent.

First, your sample did work just fine on my machine.  I did change the Northwind database to one already running on my SQL Server because I don't want to install SQL Server Express on here.  Also, with Win8/VS2012, there is a new version of SQL Server Express and I really didn't want to get into that.

Anyway...

Second, I have moved the grid in question to another project.  I re-tried all of the exporting.  When I exported to Excel, it took forever but eventually completed correctly.  When I exported to CSV, it actually exported to Excel in just a couple of seconds.  When I exported to Word, that, too, took forever.  But I waited and it did complete after a couple of minutes.

When I exported to PDF, I received an error.  I have attached a screen capture to this forum item for your review.

I should add that the grid is now running on a page that uses a master page for common header/footer/etc.

Thanks!

Lynn
0
Accepted
Kostadin
Telerik team
answered on 18 Dec 2012, 12:02 PM
Hello Lynn,

As indicated at the exception you cannot use ".." to exit the root directory. I guess when you are trying to point the path of the image you are exiting the root directory. I suggest you to remove the HyperLink text and then try to export to PDF just to check whether you will receive this exception.
hypercolumn.Text = "<img border=\"0\" alt=\"View\" src=\"../Icons/pencil_16.png\" />";

The code with yellow background is the reason for this behavior.

Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Lynn
Top achievements
Rank 2
answered on 19 Dec 2012, 03:17 AM
Kostadin,

Thank you!  That did resolve the .pdf export issue completely.  I can change the icon address easily for long-term resolution.

Thanks again!  Have a great day!

Lynn
Tags
Grid
Asked by
Lynn
Top achievements
Rank 2
Answers by
Kostadin
Telerik team
Lynn
Top achievements
Rank 2
Share this question
or