【发布时间】:2023-04-01 06:10:01
【问题描述】:
我的问题如下,当您第一次加载页面时,您会看到单元格内的文本框带有红色背景,但是当有回发时,单元格内的文本框会丢失。
加载方法填充我的gridview。
想法是当列颜色为红色时,我需要创建一个文本框并将文本框的背景设置为红色;
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);
}
}
}
【问题讨论】:
标签: c# webforms postback code-behind