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

RadGrid not binding gridview when exporting to pdf

1 Answer 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DTech
Top achievements
Rank 1
DTech asked on 21 Jul 2010, 11:45 PM
I have a gridview in a radgrid and I need to export the contents to a PDF.  Everything but the nested gridview is exporting.  When viewing the page, the grid is databound (but not when exporting to pdf).  See code below:

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage-blank.master" %>
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<script runat="server">
 
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        RadGrid1.ExportSettings.ExportOnlyData = False
        RadGrid1.ExportSettings.IgnorePaging = True
        RadGrid1.ExportSettings.OpenInNewWindow = False
        RadGrid1.BorderStyle = BorderStyle.None
        RadGrid1.MasterTableView.BorderStyle = BorderStyle.None
        RadGrid1.MasterTableView.DataBind()
        RadGrid1.MasterTableView.ExportToPdf()
    End Sub
</script>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
        DataSourceID="SqlDataSource1" GridLines="None">
        <MasterTableView datakeynames="SchoolWalkID" datasourceid="SqlDataSource1">
            <Columns>
                <telerik:GridTemplateColumn UniqueName="TemplateColumn">
                    <ItemTemplate>
                    This text exports to PDF.  The grid below binds correctly when viewing the page a browser.  When exporting to PDF, the grid is not exported.
                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                            DataSourceID="SqlDataSource2" EnableModelValidation="True">
                        </asp:GridView>
                        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
                            ConnectionString="<%$ ConnectionStrings:SQLcmsConnection %>"
                            SelectCommand="SELECT * FROM [Schools]"></asp:SqlDataSource>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:SQLcmsConnection %>"
        SelectCommand="SELECT * FROM [Schools_Walks]"></asp:SqlDataSource>
</asp:Content>

1 Answer, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 22 Jul 2010, 02:58 PM
Hello DTech,

Our PDF engine requires that all tables must have a colgroup/col elements. The ASP.NET GridView doesn't render such elements and there is no easy way to add them but to modify the raw HTML on PdfExporting event. In my opinion it would be far easier to use RadGrid instead.

Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
DTech
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or