Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2004, 06:22 PM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default update control in table

Hello,

I need to modify the properties of one HtmlInputImage from a cell in a bidimensional table.

To obtain the control HtmlInputImage I do:

HtmlInputImage image = new HtmlInputImage();
image = (HtmlInputImage)Table2.Rows[i].Cells[j].Controls[0];

Then, I modify the properties of the image.

How must I do to update the control in the same place of the table?

Thanks

-------------------------------
World only exists into your mind.
 
Old January 26th, 2004, 03:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I am not sure what you mean with your last question? With the code you have now, you'll be modifying the original image, inside the table. What exactly are you trying to do?

BTW, there is no need to set image to a new image. This will work as well:

HtmlInputImage image = (HtmlInputImage)Table2.Rows[i].Cells[j].Controls[0];

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 26th, 2004, 04:20 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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);
                    Table2.Align = "Center";
                }
                Table2.Width = Convert.ToString(nColumnas*15);

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[i].Cells[j].Controls[0];
                        //int Indice = Table2.Rows[i].Cells[j].Controls.IndexOf(image);
                        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.

-------------------------------
World only exists into your mind.
 
Old January 26th, 2004, 05:08 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry. I need nothing to refresh the image. All the problem was a bug in the logic.
Now, all is working right

-------------------------------
World only exists into your mind.





Similar Threads
Thread Thread Starter Forum Replies Last Post
update table from another db table timbal25 SQL Server 2005 3 January 19th, 2008 06:47 AM
Update one table to another table using DTS in SQL Printmaker SQL Language 0 July 24th, 2007 07:17 AM
How to Update one table with other table data? ramk_1978 SQL Language 2 May 26th, 2006 12:51 AM
update table with an ID Num from different table scoobie PHP How-To 12 January 25th, 2005 12:28 PM
Update parent table with the sum of child table gbrown SQL Language 2 November 9th, 2004 07:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.