void btnCreateBatch_Click(object sender, EventArgs e) { if (grdSubbies.Items.Count > 0 && Page.IsValid) { string jobSubConIdAndInvoiceNo = String.Empty; GridColumn invoiceColumn = this.grdSubbies.Columns.FindByUniqueName("InvoiceNo"); bool byPassCheckbox = false; if (invoiceColumn != null) { byPassCheckbox = invoiceColumn.Display; } // Get the JobSubContractIDs that we are to Invoice List <int> jobSubContractIDs = new List <int>(); foreach (GridItem row in grdSubbies.Items) { TextBox txtInvoiceNo = (TextBox)row.FindControl("txtInvoiceNo"); if (row.Selected || byPassCheckbox) { int jobSubContractID = int.Parse(row.OwnerTableView.DataKeyValues[row.ItemIndex]["JobSubContractID"].ToString()); if (!String.IsNullOrEmpty(txtInvoiceNo.Text)) { jobSubConIdAndInvoiceNo += jobSubContractID.ToString() + ":" + txtInvoiceNo.Text + ","; jobSubContractIDs.Add(jobSubContractID); } else if (byPassCheckbox == false) { jobSubContractIDs.Add(jobSubContractID); } } } Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice(); if (IsUpdate()) { facPreInvoice.UpdateBatchForSubbySelfBill(BatchID, rdiInvoiceDate.SelectedDate.Value, jobSubContractIDs, this.Page.User.Identity.Name); } else { BatchID = facPreInvoice.CreateBatchForSubbySelfBill(rdiInvoiceDate.SelectedDate.Value, jobSubContractIDs, this.Page.User.Identity.Name); } int batchID = BatchID; BatchID = -1; string url = "autorunconfirmation.aspx?bID=" + batchID.ToString(); if (!String.IsNullOrEmpty(jobSubConIdAndInvoiceNo)) { url += "&InvoiceNumbers=" + jobSubConIdAndInvoiceNo; } Response.Redirect(url); } }