Gridview: formatting some rows differently from others

Discussion in 'ASP .Net' started by tomh2099@gmail.com, Oct 9, 2007.

  1. Guest

    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.
     
    , Oct 9, 2007
    #1
    1. Advertising

  2. 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:...
    > 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.
    >
     
    Cowboy \(Gregory A. Beamer\), Oct 9, 2007
    #2
    1. Advertising

  3. Guest

    On Oct 9, 5:19 pm, "Cowboy \(Gregory A. Beamer\)"
    <> 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!
    > |
    > *************************************************<> wrote in message
    >
    > news:...
    >
    > > 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
     
    , Oct 10, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Rilling
    Replies:
    1
    Views:
    523
    Lucas Tam
    May 11, 2005
  2. Not Me
    Replies:
    0
    Views:
    502
    Not Me
    Sep 23, 2005
  3. Willem
    Replies:
    5
    Views:
    1,095
    David Dorward
    Oct 4, 2004
  4. VijayRama
    Replies:
    2
    Views:
    2,408
    Gregory A. Beamer
    Oct 12, 2009
  5. Travis
    Replies:
    3
    Views:
    421
Loading...

Share This Page