Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to change text color inside a grid view cell,I tried fore-color but it is changing the entire cell color..
Posted
Comments
nandakishoreroyal 10-Mar-14 6:06am    
can you please paste the code what you have tried..

Try This

C#
if (e.Row.RowType == DataControlRowType.DataRow)
{
   var status = (Label)e.Row.FindControl("lblStatus");
   if (status.Text == "1")
   {
      e.Row.Cells[2].Text = "IN";
      e.Row.Cells[2].BackColor = Color.Blue;
      e.Row.Cells[2].ForeColor = Color.White;
   }
}
 
Share this answer
 
 
Share this answer
 
You can easily do this using CSS. Check the id of the gridview cell (if u want to make the change in single cell only else use class instead of id) and add a css in the style tab (if using internal css else placed it in your stylesheet)

ex:
C#
//for single cell use id whatever u have applied on your grid

#grid-cell
{
 color:#666666;
}


C#
//for all cells use class name whatever u have applied on your grid

.grid-cell
{
 color:#666666;
}
 
Share this answer
 

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