Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys,

is there anyone know how to export multiple gridivew into pdf format.i manage to export only 1 gridview.

Sq
lConnection myConnection = new SqlConnection(connectionString);
        SqlCommand Command = new SqlCommand();
        Command.CommandText = "select origin ,report ,react_delay as 'reactionary delay' ,responsibility ,actions from signals_comm_failure where date = '" + TextBox1.Text + "' and id_class=1";
        Command.Connection = myConnection;
        
        using (SqlDataAdapter da = new SqlDataAdapter(Command))
        {
            DataTable dt = new DataTable();
            da.Fill(dt);
            gd_dt.DataSource = dt;
        }
        Spire.DataExport.PDF.PDFExport PDFExport = new Spire.DataExport.PDF.PDFExport();
        PDFExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
        PDFExport.DataTable = this.gd_dt.DataSource as DataTable;
        PDFExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
        PDFExport.PDFOptions.PageOptions.Orientation = Spire.DataExport.Common.PageOrientation.Landscape;
        PDFExport.SaveToFile("Report.pdf");

SqlCommand Command2 = new SqlCommand();
        Command2.CommandText = "select origin ,report ,cause ,responsibility ,actions from signals_comm_failure where date = '" + TextBox1.Text + "' and id_class =2";
        Command2.Connection = myConnection;
        using (SqlDataAdapter da2 = new SqlDataAdapter(Command2))
        {
            DataTable dt2 = new DataTable();
            da2.Fill(dt2);
            outside_dt.DataSource = dt2;
        }
        Spire.DataExport.PDF.PDFExport PDFExport = new Spire.DataExport.PDF.PDFExport();
        PDFExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
        PDFExport.DataTable = this.outside_dt.DataSource as DataTable;
        PDFExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
        PDFExport.PDFOptions.PageOptions.Orientation = Spire.DataExport.Common.PageOrientation.Landscape;
        PDFExport.SaveToFile("Report.pdf");


pls help me.

thanks in advance
musiw.
Posted
Updated 12-Jun-12 20:17pm
v2
Comments
deepakaitr12345 14-Jun-12 4:41am    
You can merge both the datatable using the datatable.merge(tempdatatable);
after doing this create the grid view using the object creation,and bind that grid view with merged datatable and pass that grid view to the pdf file.

Might be this will be more conviniant way for you. to export both the grid.

Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900