473,394 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Gridview: formatting some rows differently from others

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 '07 #1
2 2398
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!
|
*************************************************
<to******@gmail.comwrote in message
news:11**********************@g4g2000hsf.googlegro 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.

Oct 9 '07 #2
On Oct 9, 5:19 pm, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
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.comwrote in message

news:11**********************@g4g2000hsf.googlegro 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

Oct 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
0
by: Joey | last post by:
Hello all, I am trying to read a directory listing into a string and then use that data, along with some other data, to create HTML for display in a gridview row. A sample item in the string...
2
by: J055 | last post by:
Hi I've been looking into different ways of formatting columns/rows in the GridView control. I realize now, I think, that once the datasource is bound to the control the original column type...
4
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the...
2
by: Jacksm | last post by:
How can I align an asp:table columns with gridview columns (the widths)? I have tried setting table.column(0).width = gridview.column(0).width at page_load but it doesn't work. Thanks in advance
1
by: Mark Olbert | last post by:
I have a GridView as a child control in a custom composite control which is stubornly refusing to databind at design time. I'm convinced I must be missing something about how the databinding process...
1
by: Brian | last post by:
I currently have a GridView that displays information like: , Name, Address, City, State, Notes. Right now this information is displayed in columns but I would like it if each row in the table...
6
by: Sergio E. | last post by:
Hi, I'm looking for information about gridview's cell properties... I've the following case: one gridview with alternatirg row style and normalrowstyle, 3 o 4 custom styles that are applied to...
2
by: bogdan | last post by:
Hi, Can a single GridView be 'connected' to DetailsView that renders itself differently based on the currently selected row? I have a GridView with rows that could be displayed in the same way...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.