We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Exporting PDF

Thread ID:





132618 Sep 12,2017 09:29 AM Sep 13,2017 09:00 AM ASP.NET Web Forms 1
Tags: Grid
Asked On September 12, 2017 09:29 AM

Using StoredProcedure to load data to grid.
try to export to pdf after databind.
exp.Export(GVfichas.Model, DirectCast(GVfichas.DataSource, IEnumerable), "Export.pdf", True, True, "flat-lime")
error System.NullReferenceException

Protected Sub FlatGrid_ServerPdfExporting(sender As Object, e As Syncfusion.JavaScript.Web.GridEventArgs)
        Dim exp As New PdfExport()
        Me.GVfichas.DataSource = SqlDataSourcefichas
        exp.Export(GVfichas.Model, DirectCast(GVfichas.DataSource, IEnumerable), "Export.pdf", True, True, "flat-lime")
End Sub


Prasanna Kumar Viswanathan [Syncfusion]
Replied On September 13, 2017 09:00 AM

Hi Helder, 

Thanks for contacting Syncfusion support. 

In your code example you have bound sqlDatasource to Grid using StoredProcedure. To export to excel, PDF or word in grid while binding SqlDatasource, use select method of SqlDataSource. It is used to retrieves data from the underlying database by using the SelectCommand SQL string. 

Find the code example:  

<ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" AllowGrouping="true" AllowResizing="true"  OnServerPdfExporting="FlatGrid_ServerPdfExporting" AllowPaging="True" AllowFiltering="True" >        
    <asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString %>" 
            SelectCommand="SELECT * FROM [Territories]"></asp:SqlDataSource> 

protected void FlatGrid_ServerPdfExporting(object sender, GridEventArgs e) 
            PdfExport exp = new PdfExport(); 
            DataView data = (DataView)SqlData.Select(new DataSourceSelectArguments()); 
            DataTable dt = data.Table; 
            exp.Export(FlatGrid.Model, dt, "Export.pdf", true, true, "flat-lime"); 

Prasanna Kumar N.S.V 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.