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

Grid not exporting while in usercontrol

1 Answer 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ronnie
Top achievements
Rank 1
Ronnie asked on 14 Jul 2009, 08:49 PM
Good Afternoon,

I have a radgrid on a usercontrol, that is called by a parent page.  For some reason the export function will not work inside the usercontrol, but the same code will work perfect if I place it directly on the parent page.

Here is my javascript located on the Default.aspx page:
 
<script type="text/javascript">  
    function pnlRequestStarted(ajaxPanel, eventArgs)  
    {  
      if(eventArgs.EventTarget == "pnlBtnExcel" || eventArgs.EventTarget == "pnlBtnWord")  
      {  
         eventArgs.EnableAjax = false;  
      }  
    }  
</script> 

Here is the grid that will export correctly if the code is placed on the parent page:
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="pnlRequestStarted">  
            <asp:Button ID="pnlBtnExcel" Width="150px" Text="Export to Excel" OnClick="btnExcel_Click" 
                runat="server" /> 
            <asp:Button ID="pnlBtnWord" Width="150px" Text="Export to Word" OnClick="btnWord_Click" 
                runat="server" /> 
            <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" GridLines="None">  
                <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1">  
                    <RowIndicatorColumn> 
                        <HeaderStyle Width="20px" /> 
                    </RowIndicatorColumn> 
                    <ExpandCollapseColumn> 
                        <HeaderStyle Width="20px" /> 
                    </ExpandCollapseColumn> 
                    <Columns> 
                        <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" HeaderText="ID" ReadOnly="True" 
                            SortExpression="ID" UniqueName="ID">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" 
                            UniqueName="Name">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="Value" HeaderText="Value" SortExpression="Value" 
                            UniqueName="Value">  
                        </telerik:GridBoundColumn> 
                    </Columns> 
                </MasterTableView> 
            </telerik:RadGrid><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                SelectCommand="SELECT * FROM [Test]"></asp:SqlDataSource> 
        </telerik:RadAjaxPanel> 

But if I place the same code in a usercontrol and then place the usercontrol on the Default.aspx page, the data will not export.  What else am I missing, I have gone all through the sample code and haven't been able to figure it out? 

Thanks,

Ronnie

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 17 Jul 2009, 07:47 AM
Hello Ronnie,

I created a sample project that demonstrates how to export to PDF when RadGrid is residing in user control.
I use RadAjaxManager/RadAjaxManagerProxy instead of RadAjaxPanel.

Let me know if you need further assistance.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Ronnie
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or