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 10: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)

  Print Answers RSS
0 OriginalGriff 254
1 Sergey Alexandrovich Kryukov 182
2 Hard_Rockz 128
3 Richard MacCutchan 125
4 Maciej Los 104
0 OriginalGriff 5,374
1 Sergey Alexandrovich Kryukov 4,713
2 Peter Leow 2,944
3 DamithSL 2,465
4 Maciej Los 2,270


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