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

Trying to export my grid, exports entire aspx page instead

3 Answers 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jack Voss
Top achievements
Rank 1
Jack Voss asked on 30 Nov 2011, 09:02 PM
Either grid on this page will, instead of exporting the grid and it's data, give me an export of the entire aspx page. 
I have no idea what is going on with.  Things work fine with the export on the other pages, at least I do get an excel file.

If anyone has any ideas, I would appreciate the feedback.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RMAGenerator.aspx.cs" Inherits="ECSMT.RMAGenerator" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title>JDE RMA Grid Creation</title>
    <script src="/Scripts/modernizr-2.0.6.min.js" type="text/javascript"> </script>
    <style>
       section 
            {
                background: #cfdbe6;
                margin: 20px;
                padding: 5px;              
                border-radius: 10px;
                box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.5);
                background: cfdbe6;
                width: 95%;
                color: #696969;
                font-size: 12px;
            }
        section h1 {font-size: 16px; font-weight: bold; color:Navy }
        section h2 {font-size: 12px; font-weight: bold; text-decoration: underline}
        .MyImageButton
        {
            cursor: hand;
        }
        .EditFormHeader td
        {
            font-size: 14px;
            padding: 4px !important;
            color: #0066cc;
        }
 
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rgrdRMA">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgrdRMA" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="rbtnAppend">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rbtnAppend"></telerik:AjaxUpdatedControl>
                        <telerik:AjaxUpdatedControl ControlID="rgrdRMA" LoadingPanelID="RadAjaxLoadingPanel1" ></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
<%--                <telerik:AjaxSetting AjaxControlID="rbtnExport">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rbtnExport"></telerik:AjaxUpdatedControl>
                        <telerik:AjaxUpdatedControl ControlID="rgrdExpXl" LoadingPanelID="RadAjaxLoadingPanel1" ></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>--%>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default" Width = "100%" Height="100%">
        </telerik:RadAjaxLoadingPanel>
            <h3>RMA Generator</h3>
            <h1>CEI:<asp:Label ID="lblCEI" runat="server" Text="0"></asp:Label>
            CMT:<asp:Label ID="lblCMT" runat="server" Text="0"></asp:Label></h1>
            <h3><asp:Label ID = "lblCustInfo" runat="server" Text="Customer Information" ></asp:Label></h3>
 
            <telerik:RadGrid ID="rgrdRMA" runat="server" GridLines="Both" Skin="Windows7" AllowPaging="False" AllowSorting="false"
                AutoGenerateColumns="False"  OnNeedDataSource="rgrdRMA_NeedDataSource" OnUpdateCommand="rgrdRMA_UpdateCommand"
                 OnInsertCommand="rgrdRMA_InsertCommand"  OnDeleteCommand="rgrdRMA_DeleteCommand" ShowStatusBar="true">
                <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="RowNumber"
                         AutoGenerateColumns="False" EditMode="InPlace" >
                    <Columns>
                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                        </telerik:GridEditCommandColumn>
                        <telerik:GridDropDownColumn DataField="LastDispo" DataSourceID="SqlDataSource1"
                            HeaderText="LastDispo" ListTextField="DescOne" ListValueField="LastDispo"
                            UniqueName="LastDispo" >
                        </telerik:GridDropDownColumn>
                        <telerik:GridDropDownColumn DataField="LITM" DataSourceID="SqlDataSource2"
                            HeaderText="LITM" ListTextField="DSC" ListValueField="LITM"
                            UniqueName="LITM" >
                        </telerik:GridDropDownColumn>
                        <telerik:GridNumericColumn UniqueName="ReturnQty" SortExpression="ReturnQty" HeaderText="ReturnQty"
                        DataField="ReturnQty" />
                        <telerik:GridDropDownColumn DataField="ReturnEquipNum" DataSourceID="EquipmentForReceipt"
                            HeaderText="ReturnEquipNum" ListTextField="BigDescrip" ListValueField="ReturnEquipNum"
                            UniqueName="ReturnEquipNum" >
                        </telerik:GridDropDownColumn>
                        <telerik:GridBoundColumn UniqueName="ReturnSerialNum" SortExpression="ReturnSerialNum" HeaderText="ReturnSerialNum"
                            DataField="ReturnSerialNum" ReadOnly="true"  />
                        <telerik:GridBoundColumn UniqueName="IncomingLocCode" SortExpression="IncomingLocCode" HeaderText="IncomingLocCode"
                        DataField="IncomingLocCode" />
                        <telerik:GridDropDownColumn DataField="ShipToAddr" DataSourceID="ShipTosFilteredByCMT"
                            HeaderText="ShipToAddr" ListTextField="ShipToAddr" ListValueField="ShipToAddr"
                            UniqueName="ShipToAddr" >
                        </telerik:GridDropDownColumn>
                        <telerik:GridNumericColumn UniqueName="ReplacementQty" SortExpression="ReplacementQty" HeaderText="ReplacementQty"
                        DataField="ReplacementQty" />
                        <telerik:GridNumericColumn UniqueName="ReplacementEquipID" SortExpression="ReplacementEquipID" HeaderText="ReplacementEquipID"
                            DataField="ReplacementEquipID" />
                        <telerik:GridBoundColumn UniqueName="OutgoingLocCode" SortExpression="OutgoingLocCode" HeaderText="OutgoingLocCode"
                            DataField="OutgoingLocCode" />
                        <telerik:GridBoundColumn UniqueName="RequestedShipDate" SortExpression="RequestedShipDate" HeaderText="RequestedShipDate"
                            DataField="RequestedShipDate" ReadOnly="true"/>
                        <telerik:GridButtonColumn UniqueName="DeleteColumn" CommandName="Delete" ButtonType="LinkButton" Text="Delete" />
                    </Columns>
                 </MasterTableView>
            </telerik:RadGrid>
 
 
             <asp:Table ID="tblControls" runat="server" Width="100%">
                <asp:TableRow  Width = "100%">
                    <asp:TableCell Width="20%" HorizontalAlign="Right" >
                        <h1>Append RMA Product For</h1>
                    </asp:TableCell>
                    <asp:TableCell Width="30%" HorizontalAlign="Right" >
                        <telerik:RadComboBox ID="rcmbProduct" Runat="server" Width="100%" AutoPostBack="true" ></telerik:RadComboBox>
                    </asp:TableCell>
                    <asp:TableCell Width="10%" HorizontalAlign="Left" >
                        <telerik:RadButton ID="rbtnAppend" runat="server" Text="Append" OnClick="rbtnAppend_Click" AutoPostBack="true"></telerik:RadButton>
                    </asp:TableCell>
                    <asp:TableCell Width="40%" HorizontalAlign ="Justify">
                        <telerik:RadButton ID="rbtnExport" runat="server" Text="Export"  OnClick="rbtnExport_Click" AutoPostBack="true"></telerik:RadButton>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow >
                    <asp:TableCell Width="20%" HorizontalAlign="Center" >
                        <asp:Label ID="lblCurPC" Text="Current PC:" runat="server"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell Width="20%" HorizontalAlign="Center" >
                        <asp:Label ID="lblCurPCType" Text="Current PC Type:" runat="server"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell Width="20%" HorizontalAlign="Center" >
                        <asp:Label ID="lblCurScreenSKU" Text="Current Screen SKU :" runat="server"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell Width="40%" HorizontalAlign ="Center">
                    </asp:TableCell>
                </asp:TableRow>
            </asp:Table>
 
            <telerik:RadGrid ID="rgrdExpXl" runat="server" GridLines="Both" Skin="Windows7" AllowPaging="False"
                AutoGenerateColumns="False" OnNeedDataSource="rgrdExpXl_NeedDataSource"  >
                <MasterTableView Width="100%" AutoGenerateColumns="False" >
                    <Columns>
                        <telerik:GridBoundColumn DataField="LastDispo" HeaderText="" UniqueName="LastDispo" />
                        <telerik:GridBoundColumn DataField="LITM" HeaderText="" UniqueName="LITM" />
                        <telerik:GridNumericColumn UniqueName="ReturnQty" HeaderText="" DataField="ReturnQty" />
                        <telerik:GridBoundColumn DataField="ReturnEquipNum" HeaderText="" UniqueName="ReturnEquipNum" />
                        <telerik:GridBoundColumn UniqueName="ReturnSerialNum" HeaderText="" DataField="ReturnSerialNum" />
                        <telerik:GridBoundColumn UniqueName="RequestedShipDate" HeaderText="" DataField="RequestedShipDate" />
                        <telerik:GridBoundColumn DataField="LITM" HeaderText="" UniqueName="LITM2" />
                        <telerik:GridBoundColumn DataField="ShipToAddr" HeaderText="" UniqueName="ShipToAddr" />
                        <telerik:GridNumericColumn UniqueName="ReplacementEquipID" HeaderText="" DataField="ReplacementEquipID" />
                        <telerik:GridNumericColumn UniqueName="ReplacementQty" HeaderText="" DataField="ReplacementQty" />
                        <telerik:GridNumericColumn UniqueName="ReturnQty2" HeaderText="" DataField="ReturnQty" />
                        <telerik:GridNumericColumn UniqueName="LineNumber" HeaderText="" DataField="LineNumber" />
                        <telerik:GridBoundColumn UniqueName="IncomingLocCode" HeaderText="" DataField="IncomingLocCode" />
                        <telerik:GridBoundColumn UniqueName="OutgoingLocCode" HeaderText="" DataField="OutgoingLocCode" />
                    </Columns>
                 </MasterTableView>
            </telerik:RadGrid>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:JDECommon %>"
                ProviderName="System.Data.SqlClient" SelectCommand="uspGetLastDispoForRMAGrid">
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:JDECommon %>"
                ProviderName="System.Data.SqlClient" SelectCommand="uspGetRMASKUS">
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="ShipTosFilteredByCMT" runat="server"
                ConnectionString="<%$ ConnectionStrings:JDECommon %>"
                SelectCommand= "uspGetRMAShipTos @CMT">
                <SelectParameters>
                    <asp:ControlParameter ControlID="lblCMT" Name="CMT"
                        PropertyName="Text" />
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="EquipmentForReceipt" runat="server"
                ConnectionString="<%$ ConnectionStrings:JDECommon %>"
                SelectCommand= "uspGetRMAOutboundEquipmentForCEI @CEI ">
                <SelectParameters>
                    <asp:ControlParameter ControlID="lblCEI" Name="CEI"
                        PropertyName="Text" />
                </SelectParameters>
            </asp:SqlDataSource>
 </form>
</body>
<script type="text/javascript">
    Modernizr.load([{
        complete: function ()
        {
            if (!window.jQuery)
            {
                Modernizr.load('/Scripts/jquery-1.6.1.min.js');
            }
        }
    },
        {
            test: Modernizr.borderradius || Modernizr.boxshadow,
            nope: '/Scripts/PIE.js',
            callback: function ()
            {
                $('section').each(function ()
                {
                    PIE.attach(this);
                });
            }
        }]);
    </script>
 
</html>

3 Answers, 1 is accepted

Sort by
0
Pablo
Top achievements
Rank 1
answered on 30 Nov 2011, 10:17 PM
Try the following:

Paste the following markup in your grid right before the element <MasterTableView...

<ExportSettings ExportOnlyData="True" IgnorePaging="true" OpenInNewWindow="true">
                    <Excel Format="ExcelML" />
     </ExportSettings>


Then in your code do the following 

for rgrdRMA grid:

 this.rgrdRMA.MasterTableView.ExportToExcel();

for rgrdExpXl grid: 

 this.rgrdExpXl.MasterTableView.ExportToExcel();

0
Jack Voss
Top achievements
Rank 1
answered on 01 Dec 2011, 09:12 PM
I actually set those export setting in the codebehind when they click the button to export.

The problem was not in the code, the problem was coming from my IE settings.  

I deleted all of my temporary files, cookies, saved passwords, and web information. 
Then Restored the Advanced settings , Reset internet expolorer to it's default settings and the export started working.   This is not the first time we have run across weird problems with explorer.  We have had peoples IE not display grids properly and complete the opening of a page and hang.  All so far were fixed by reseting explorerer.  


0
Shinu
Top achievements
Rank 2
answered on 02 Dec 2011, 04:26 AM
Hello Jack,

The exporting feature of the RadGrid work with regular postbacks only. Since you have ajaxified your RadGrid, you need to explicitly disable its ajax mode to export with regular postback. Check the following help documentation which explains the same.
Export from Ajaxified Grid

-Shinu.
Tags
Grid
Asked by
Jack Voss
Top achievements
Rank 1
Answers by
Pablo
Top achievements
Rank 1
Jack Voss
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or