protected void Delete_Click(object sender, EventArgs e) { try { int i = 0; Table TBL = new Table(); TBL = (Table)(Session["MessageTbl"]); int num = TBL.Rows.Count; foreach (TableRow x in TBL.Rows) { if (((x.Cells[1].Text) != "הודעות") && (i < num - 1)) { CheckBox itemBox = divmessage.FindControl("ChekBox" + i.ToString()) as CheckBox; i++; if (itemBox.Checked == true) { DBservices.DeleteMessage(x.Cells[1].Text); } } } Response.Redirect("message.aspx"); } catch (Exception ex) { ErrHandler.WriteError(ex.Message); Response.Write("ארעה שגיאה"); } }