如何动态更改位于gridview内的文本框的颜色 [英] How to dynamically change the color of textbox that lies inside a gridview

查看:75
本文介绍了如何动态更改位于gridview内的文本框的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在以下代码中更改TextBox对象'tbqty'的颜色。我在两个颜色更改选项中都没有出错,但颜色没有变化。有没有可能?



I tried to change the color of TextBox object 'tbqty' in the following code. I get no error in both the color change options but the color is not getting changed. Is there any possibilities?

protected void grvcart_RowEditing(object sender, GridViewEditEventArgs e)
    {
      int rowIndex = Convert.ToInt32(e.NewEditIndex);
      string v_RowNumber = grvcart.Rows[rowIndex].Cells[0].Text;
      TextBox tbqty = grvcart.Rows[e.NewEditIndex].Cells[3].FindControl("tbqty") as TextBox;
      tbqty.BackColor = System.Drawing.ColorTranslator.FromHtml("#F2F0E1");
      tbqty.Attributes["style"] = "color:red";

推荐答案

参考下面的代码在这里执行此操作,gvSoldUnSoldProductList是Gridview的ID

refer the following code to do this here,gvSoldUnSoldProductList is the ID of Gridview
foreach (GridViewRow gvr in gvSoldUnSoldProductList.Rows)
           {
           (TextBox)gvr.FindControl("txtQuantity")).ForeColor=System.Drawing.Color.red
           }


这篇关于如何动态更改位于gridview内的文本框的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆