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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Exporting PDF

Thread ID:

Created:

Updated:

Platform:

Replies:

132618 Sep 12,2017 01:29 PM UTC Sep 13,2017 01:00 PM UTC ASP.NET Web Forms 1
loading
Tags: Grid
Helder
Asked On September 12, 2017 01:29 PM UTC

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:

Prasanna Kumar Viswanathan [Syncfusion]
Replied On 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 


CONFIRMATION

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.

Warning Icon 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.Close Icon

;