Click here to Skip to main content
12,996,849 members (132,557 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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 3-Feb-13 17:04pm
   
Try it changing the color after binding the grid.
Member 1474407 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

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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2017
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