Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Gridview
Hi there!
 
My GridView is into Repeater.
 
So after its binding I'm trying to change font color of the 2nd column.
 
       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 3-Feb-13 11:53am
Comments
Irbaz Haider Hashmi at 3-Feb-13 17:04pm
   
Try it changing the color after binding the grid.
Member 1474407 at 3-Feb-13 17:32pm
   
Thanks! The proper event is GridView1_RowDataBound.
Irbaz Haider Hashmi at 3-Feb-13 17:36pm
   
Thats what i want you to search out. :)
RowDataBound is binding the grid with data.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Solved!
 
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
       {
           e.Row.Cells[1].ForeColor = System.Drawing.Color.Red;
       }
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.150326.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100