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. Image for the cookie policy date

Exporting PDF

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

using
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

error:

1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team September 13, 2017 01:00 PM UTC

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" >        
      ------------------- 
       </ej:Grid> 
    <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"); 
        } 

Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon