Sk Jha

Sk Jha

  • 1.8k
  • 79
  • 12.5k

change back color if gridView cells has empty.

Dec 21 2017 3:16 AM
how to change specific cells backcolor if cells has no data in gridview in asp.net
 
my code is here.. 
  1. for (int i = 0; i < GridView1.Row.Cells.Count; i++)  
  2.  {  
  3.     
  4.             if (GridView1.Row[i].Cells[2].Text == "")  
  5.             {  
  6.                 GridView1.Row[i].Cells[2].BackColor = Color.Red;  
  7.             }  
  8.            else  
  9.            {  
  10.                 GridView1.Row[i].Cells[2].BackColor = Color.Green;                    
  11.            }  
  12. }  

Answers (5)