protected void btnCancel_Click(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { CheckBox chk = (CheckBox)row.FindControl("chkSelect"); if (chk.Checked == true) { int autoId = int.Parse(GridView1.DataKeys[row.RowIndex].Value.ToString()); CancelTicketClass cancelInstance = new CancelTicketClass(); cancelInstance.CancelTicket(autoId, Session["selectedBookingId"].ToString(), "101"); } } Response.Redirect("BookingHistory.aspx"); }