So first I'm getting everything from the database and adding a checkbox for each line of new data, this is all working:
while (reader.Read()) {
idtema = "";
nome = "";
filename[i] = "";
TableRow rows = new TableRow();
TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
TableCell cell4 = new TableCell();
CheckBox ch = new CheckBox();
idtema = reader["IDTema"].ToString();
nome = reader["NomeArtista"].ToString();
filename[i] = reader["FileNameTrabalho"].ToString();
cell1.Text = idtema;
cell2.Text = nome;
cell3.Text = string.Format("<a href='/Tema" + idtema + "/" + filename[i] + "' data-lightbox='images1'><img height='100%' src = '/Tema" + idtema + "/" + filename[i] + "'>");
cell4.Controls.Add(ch);
rows.Cells.Add(cell1);
rows.Cells.Add(cell2);
rows.Cells.Add(cell3);
rows.Cells.Add(cell4);
TabelaPrincipal.Rows.Add(rows);
Button1.Visible = true;
i = i + 1;
}
con.Close();
After this I check my 4 checkboxes and I press the button to read the data:
public void Button1_Click(object sender, EventArgs e)
{
int check = 0;
foreach (Control item in this.TabelaPrincipal.Controls)
{
if((item is CheckBox) && ((CheckBox) item).Checked)
{
TabelaPrincipal.Visible = false;
Button1.Visible = false;
DropArtista.Visible = false;
DropEscola.Visible = false;
DropConcelho.Visible = false;
}
else
{
check += 1;
Response.Write(check);
}
}
}
The response.write comes back "1" and that's it (not even checking if its selected), how do I change so it reads all my checkboxes and the collumns?
Aucun commentaire:
Enregistrer un commentaire