Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Gridview: formatting some rows differently from others

Reply
Thread Tools

Gridview: formatting some rows differently from others

 
 
tomh2099@gmail.com
Guest
Posts: n/a
 
      10-09-2007
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.

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      10-09-2007
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!
|
*************************************************
<> wrote in message
news: ups.com...
> 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.
>



 
Reply With Quote
 
 
 
 
tomh2099@gmail.com
Guest
Posts: n/a
 
      10-10-2007
On Oct 9, 5:19 pm, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamM> wrote:
> 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!
> |
> *************************************************< tomh2...@gmail.com> wrote in message
>
> news: ups.com...
>
> > 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.


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamically add new rows and save data typed in these rows to a database Arjen Hoekstra ASP .Net 0 08-02-2005 12:15 PM
convert rows to columns and columns to rows helpful sql ASP .Net 0 05-19-2005 06:03 PM
Scrolling some table rows while locking others. Peter Rilling ASP .Net 1 05-11-2005 03:50 PM
script for moving rows up and down and traverse thru rows of HTML table Subba Rao via DotNetMonster.com ASP .Net 0 03-19-2005 06:46 AM
CSS formatting anchor differently based on enclosing div Willem HTML 5 10-04-2004 09:04 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57