protected void btnProcess_Click(object sender, EventArgs e) { try { string[] invoices = gvwMaster.Rows.Cast <GridViewRow>().Where(row => (row.Cells[row.Cells.Count - 1].Controls[1] as CheckBox).Checked).Select(row => row.Cells[0].Text).ToArray(); string fileName = BillingService.GenerateBillingUnpaidInvoice( Convert.ToInt32(ddlBranch.SelectedValue), invoices, Server.MapPath("~/billing/")); litResult.Text = String.Format("Billing result file <b><a target='_new' href='{0}'>{1}</a></b>", this.ResolveClientUrl("~/billing/" + fileName), fileName); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "_alert", "alert('" + ex.Message + "');", true); } }