ViewState Problem

Discussion in 'C#' started by shabareka, Jul 16, 2009.

  1. #1
    I have a gridview. Two of the columns are a textbox and an imagebutton. When I press one of the imagebuttons I want to change the background colour of the textbox at the same row. When I press another imagebutton I want to change the colour of its textbox as well. But I want the previous textboxes to remain coloured. So EnableViewState should be true. The problem is the first time I press an imagebutton, the textbox colour does not change. Here is the code I use

    protected void AddButton_Click(object aSender, EventArgs e)   
    {   
                ((aSender as ImageButton).NamingContainer.FindControl("tbQty") as TextBox).BackColor = System.Drawing.Color.Aquamarine;   
    }
    Code (markup):

     
    shabareka, Jul 16, 2009 IP