Click here to Skip to main content
15,878,316 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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?

C#
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";
Posted

1 solution

refer the following code to do this here,gvSoldUnSoldProductList is the ID of Gridview
C#
foreach (GridViewRow gvr in gvSoldUnSoldProductList.Rows)
           {
           (TextBox)gvr.FindControl("txtQuantity")).ForeColor=System.Drawing.Color.red
           }
 
Share this answer
 
Comments
S.Rajendran from Coimbatore 21-Nov-13 0:06am    
asks defenition and extension for forecolor

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900