Export to Excel from usercontrol

4 posts, 1 answers
  1. Esk
    Esk avatar
    11 posts
    Member since:
    Sep 2007

    Posted 26 Jun 2008 Link to this post


    I have a grid that has sorting, filtering and export to excel functionality by design. This grid is part of a user control page that is loaded inside of a content asp panel from the parent page. The default.aspx page has the script manager and radajax manager, the later is configured to update the content page when the header or footer are clicked but not it self.

    The issue i am having is I cant seem to be able to trigger the export to excel function of the grid. It works fine in a aspx page, but not at all in my usercontrol.
    I have read all the posted information and reviewed all available projects regarding working with export in ajax projects. The closest one i saw is exporting from a content page that is loaded by a master page, however that example didn't work either for my practicular environment. 

    I tried using Ajax Manager Proxy but no luck so far. Can you please post an example of how to make the export work for a usercontrol scenario in C#? 

    Update :  I managed to get it to work somewhat except it only works on the 2nd click of the btnExcel and every click there after.  
    This is my code:

    protected void btnExcel_Click(object sender, EventArgs e)  
               RadAjaxManager ram = (RadAjaxManager)this.Page.FindControl("ramManager");  
               ram.EnableAJAX = false;  
                gReports.PageSize = gReports.MasterTableView.VirtualItemCount;  
                gReports.ExportSettings.IgnorePaging = true;  
                gReports.ExportSettings.ExportOnlyData = true;  

    1 <asp:Button ID="btnExcel" Width="150px" Text="Export to Excel" CommandName="Export" runat="server" OnClick="btnExcel_Click" /> 
    3 <telerik:RadGrid ID="gReports" ShowStatusBar="True" Skin="WebBlue" GridLines="None" 
    4         AllowSorting="True" AllowPaging="True" PageSize="20" Width="100%" runat="server" 
    5         AllowFilteringByColumn="True" AutoGenerateColumns="False" ItemStyle-Wrap="false" 
    6         OnItemCommand="gReports_ItemCommand">  
    7         <MasterTableView TableLayout="Auto" DataKeyNames="service_request_id" CellPadding="3" GridLines="None">  
    8             <Columns> 
    9                 <telerik:GridTemplateColumn UniqueName="ViewRequestColumn" AllowFiltering="False" HeaderStyle-Width="30px" ItemStyle-Width="30px">  
    10                     <ItemTemplate> 
    11                         <asp:LinkButton ID="lbView" runat="server" CommandName="ShowDetails">View</asp:LinkButton> 
    12                     </ItemTemplate> 
    13                     <HeaderStyle Width="30px" /> 
    14                     <ItemStyle Width="30px" /> 
    15                 </telerik:GridTemplateColumn> 
    16                 <telerik:GridBoundColumn HeaderText="Claim Number" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" 
    17                     DataField="claim_no" UniqueName="claim_no">  
    18                 </telerik:GridBoundColumn> 
    19             </Columns>            
    20         </MasterTableView> 
    21         <ClientSettings> 
    22             <Selecting AllowRowSelect="True" EnableDragToSelectRows="False" /> 
    23             <Scrolling AllowScroll="True" ScrollHeight="457px" UseStaticHeaders="True" SaveScrollPosition="True">  
    24             </Scrolling> 
    25         </ClientSettings> 
    26       </telerik:RadGrid> 

    <telerik:RadScriptManager ID="RadScriptManager" runat="server" /> 
        <telerik:RadAjaxManager ID="ramManager" runat="server" > 
                <telerik:AjaxSetting AjaxControlID="pHeader">  
                        <telerik:AjaxUpdatedControl ControlID="rapCrumb" /> 
                        <telerik:AjaxUpdatedControl ControlID="rapContent" LoadingPanelID="rlpLoading" /> 
                <telerik:AjaxSetting AjaxControlID="pFooter">  
                        <telerik:AjaxUpdatedControl ControlID="rapCrumb" /> 
                        <telerik:AjaxUpdatedControl ControlID="rapContent" LoadingPanelID="rlpLoading" /> 
        <div id="dFrame">  
            <div id="dContent">  
                <asp:Panel ID="rapContent" runat="server">  
     As expected after that the sorting, view details and the whole webpage navigation stops working because the ajax remains disabled.
    Can you please help me correct that behaviour so it actualy works on the first click and does not affect the rest of the application functionality?

    Blagodaria vi mnogo za vremeto vi I se izveniavam za bezpokoistvoto.
  2. Esk
    Esk avatar
    11 posts
    Member since:
    Sep 2007

    Posted 27 Jun 2008 Link to this post

    would you be able to help here or do i need to open a support ticket?
  3. Answer
    Yavor avatar
    11 posts

    Posted 30 Jun 2008 Link to this post

    Hi Esk,

    Basically, in order for the export to work, you should disable the Ajax functionality during the export.
    The code supplied does not provide enough information on the structure of the project. It would be best if you open a formal support ticket, and send us a small working project, demonstrating the setup, as well as the issue. We will review it locally, and advise you further.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  4. Esk
    Esk avatar
    11 posts
    Member since:
    Sep 2007

    Posted 30 Jun 2008 Link to this post

    Ok I opened a support ticket.

Back to Top