Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there!

My GridView is into Repeater.

So after its binding I'm trying to change font color of the 2nd column.

C#
protected void Page_Load(object sender, EventArgs e)
 {
     GridView gv = (GridView)Page.FindControl("GridView1");
     gv.Columns[1].ControlStyle.ForeColor = System.Drawing.Color.Red;
 }

But got an error.

What event should I use?


Thank you!
Posted
Comments
Irbaz Haider Hashmi 3-Feb-13 17:04pm    
Try it changing the color after binding the grid.
The_Immortal 3-Feb-13 17:32pm    
Thanks! The proper event is GridView1_RowDataBound.
Irbaz Haider Hashmi 3-Feb-13 17:36pm    
Thats what i want you to search out. :)
RowDataBound is binding the grid with data.

1 solution

Solved!

C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
       {
           e.Row.Cells[1].ForeColor = System.Drawing.Color.Red;
       }
 
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