protected void btnInativar_Click(object sender, EventArgs e) { //Response.Write("<script>alert('Mama mia fora ." + grwEventos.Rows.Count + " ');</script>"); int aux = grwEventos.Rows.Count; for (int cont = 0; cont < aux; cont++) { //Response.Write("<script>alert('Mama mia ."+ grwEventos.Rows.Count+" ');</script>"); string strCmd = null; CheckBox check = (CheckBox)grwEventos.Rows[cont].FindControl("CheckBox1"); Label lbCod = (Label)grwEventos.Rows[cont].FindControl("Label1"); Label lbStat = (Label)grwEventos.Rows[cont].FindControl("label2"); if (check.Checked == true) { if (lbStat.Text.Equals("A")) { strCmd = string.Format("UPDATE EVENTO SET STATUS = 'I' WHERE COD_EVENTO = {0}", lbCod.Text); } else if (lbStat.Text.Equals("I")) { EventoDAO evd = new EventoDAO(); int ret = evd.ativarEvento(lbCod.Text); if (ret == 1) { strCmd = "tetete"; } else { Response.Write("<script>alert('Evento com data de fim anterior a data atual.');</script>"); } } else { strCmd = null; } if (strCmd != null) { SqlDB.Instancia.FazerUpdate(strCmd); Response.Write("<script>alert('Status Alterado');</script>"); Response.Redirect(Request.RawUrl); } else { Response.Write("<script>alert('Status não pode ser alterado.');</script>"); } } } }