update control in table

M

miguel.ossa

Hi to all!

I've created a table with n x n elements, in the way:

imagen = Array.CreateInstance( typeof(HtmlInputImage), nFilas,
nColumnas);
Panel1.Height = nColumnas * 15 + 2;
for (int j=0; j<nFilas; j++)
{
HtmlTableRow r = new HtmlTableRow();
r.BgColor="Gainsboro";
r.Height = "15";
for (int i=0; i<nColumnas; i++)
{
HtmlTableCell c = new HtmlTableCell();
HtmlInputImage image = new HtmlInputImage();
image.Src = "images/tapada.jpg";
image.ServerClick += new
ImageClickEventHandler(Imagen_ServerClick);
imagen.SetValue(image, j, i);
c.Controls.Add((HtmlInputImage)imagen.GetValue(j, i));
c.Height = "15";
r.Cells.Add(c);
}
Table2.Rows.Add(r);
}

The name of the image has to change if the user clicks on it. If the
images changes, I don't need anymore the event handling. I want to
change the image and deassing the handler.

for (int i=0; i<nFilas; i++)
{
// TODO: recreación de las imágenes según estado de cada casilla
for (int j=0; j<nColumnas; j++)
{
if (tablero.casilla(i,j) != tablero_old.casilla(i,j))
{
HtmlInputImage image = new HtmlInputImage();
image = (HtmlInputImage)Table2.Rows.Cells[j].Controls[0];
if (tablero.casilla(i,j) ==
TableroBuscaminas.EstadoCasilla.Vacia)
{
image.Src = "images/destapada.jpg";
image.ServerClick -= new
ImageClickEventHandler(Imagen_ServerClick);
}
}
}
}

Doing like above, I change the image, but I need also to update it
again in the table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top