void btnExportToCSVWithDetail_Click(object sender, EventArgs e) { var selectedInvoiceIds = GetSelectedInvoiceIds(); if (selectedInvoiceIds.Any()) { Facade.IInvoice facInvoice = new Facade.Invoice(); var invoiceIDs = string.Empty; foreach (int i in selectedInvoiceIds) { invoiceIDs += i.ToString() + ","; } invoiceIDs = invoiceIDs.Substring(0, invoiceIDs.Length - 1); DataSet ds = facInvoice.GetForExportWithDetail(invoiceIDs); Session["__ExportDS"] = ds.Tables[0]; Server.Transfer("../Reports/csvexport.aspx?filename=InvoiceAudit.csv"); } }