Gridview: formatting some rows differently from others

T

tomh2099

Hi,
Hi,
I have an ASP.NET 2005 application (using VB) with a GridView control
that needs to have the last 5 or 6 rows in Bold or maybe some other
special formatting. Most of the rows show monthly info but the last
few show other information. The gridview is bound to a stored
procedure that returns data something like this:

'Jan 2007', 0
'Feb 2007', 8
'Mar 2007', 8
....
'Dec 2007', 0
'Total Earned Hours', 120
'Total Used Hours', 40
'Total Earned as of today', 50


Is there a way to give the last 3 rows a different format, let's say
simply make the text bold in those rows? I've seen some discussion
about using a Footer row template, but obviously that won't work for
this case.
 
C

Cowboy \(Gregory A. Beamer\)

Yes, you can use the Row binding event to alter the normal bind and do
whatever you want. It is one of the easiest ways to set up conditional
formatting of output.
 
T

tomh2099

Yes, you can use the Row binding event to alter the normal bind and do
whatever you want. It is one of the easiest ways to set up conditional
formatting of output.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|

Thanks! I used the RowDataBound event and using the code below,
found I have access to all the row formatting properties. Just what I
needed

Here's my code

Protected Sub gvSummary_RowDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
gvSummary.RowDataBound
Dim args As GridViewRowEventArgs
args = DirectCast(e, GridViewRowEventArgs)
If args.Row.RowIndex > 12 Then 'or whatever criteria you want
args.Row.BackColor = Drawing.Color.DarkBlue
End If
End Sub

Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top