0

My problem is the following, when you load the page for the first time you see the textbox inside the cell with the red background, but when there is a postback the textbox inside the cell is lost.

load method fill my gridview.

the idea is when the column color is red, i need to create a textbox and put the background of the textbox red;

 protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                Load();
            }
           

        }
 protected void GvCriticidad_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
      if (e.Row.Cells[2].Text == "RED") {
          System.Web.UI.WebControls.TextBox txt = new System.Web.UI.WebControls.TextBox();
          txt.Enabled = false;
          txt.Width = 35;
          txt.Height = 30;
          txt.BackColor = ColorTranslator.FromHtml("#FD0707");
          e.Row.Cells[2].Text = "";
          e.Row.Cells[2].Controls.Add(txt);
                
        }
      
     }


 }

alberto mora
  • 65
  • 1
  • 8

1 Answers1

0

What are you doing on postback? Are you calling for the grid to load again? Based on what you shared the textbox won't show because a postback has occurred there for not calling the Load() method. Does removing the !PostBack check and just calling load every time resolve your issue?

 protected void Page_Load(object sender, EventArgs e)
    {
       Load();

    }
JobesK
  • 347
  • 1
  • 2
  • 6