Try Below code only change the class and method inside
DataTable dt = new DataTable();
dt = Module.fillgridProject();
try
{
if (dt.Rows.Count > 0)
{
ReportDocument rptdoc = new ReportDocument();
rptdoc.Load(Server.MapPath("~\\Reports\\ModuleReport.rpt"));
rptdoc.SetDataSource(dt);
ExportOptions exportOpts1 = rptdoc.ExportOptions;
rptdoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
rptdoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
rptdoc.ExportOptions.DestinationOptions = new DiskFileDestinationOptions();
((DiskFileDestinationOptions)rptdoc.ExportOptions.DestinationOptions).DiskFileName = Server.MapPath("ProjectReport.pdf");
rptdoc.Export();
rptdoc.Close();
rptdoc.Dispose();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=ProjectReport.pdf");
Response.WriteFile("ProjectReport.pdf");
Response.Flush();
Response.Close();
System.IO.File.Delete(Server.MapPath("ProjectReport.pdf"));
}
else
{
Messagebox1.Show("No Record for this Project");
}
}
catch
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "Hello", "javascript:alert('No Data Present');", true);
}