473,795 Members | 2,865 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2420
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.goog legroups.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.netNoS pamMwrote:
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...@g mail.comwrote in message

news:11******** **************@ g4g2000hsf.goog legroups.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_RowDa taBound(ByVal sender As Object, ByVal e
As System.Web.UI.W ebControls.Grid ViewRowEventArg s) Handles
gvSummary.RowDa taBound
Dim args As GridViewRowEven tArgs
args = DirectCast(e, GridViewRowEven tArgs)
If args.Row.RowInd ex 12 Then 'or whatever criteria you want
args.Row.BackCo lor = Drawing.Color.D arkBlue
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
5677
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 GridView to allow entry of quantity and Y/N switch for
0
1401
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 might look like this... <div style='vertical-align:middle;'><img src='image.jpb'><a href='somefile.zip'>somefile.zip</a></div> I then bind the array to a gridview to show on the form.
2
2701
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 information is lost, i.e. converted to a string. So my question is: is it better to format data while it's still in a DataTable, for example, then bind it to the control, or format the strings in the BoundField elements, or if more flexibility is...
4
8336
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 date column always shows the date and time while I just want the short date. I have tried applying a format string {0:d} but to no avail. I saw a lot of posts regarding the htmlencode property but I do not know how to turn that off for a...
2
11725
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
4129
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 works differently at design time. Here is the code that constructs the GridView in CreateChildControls(): gridSearch = new GridView(); gridSearch.AutoGenerateColumns = true; CommandField cmdField = new CommandField();
1
297
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 actually containted the address information on the first line and the note information on a line below it - yet have it still be one row within the GridView. Is this possible? To be more specific - I guess each row in the GridView would consist of...
6
6484
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 cells in the row_databound event, and now I nedd to do a excel export of the gridview exactly as is showed in the browser, but al the examples and thigs I've tried don't send the cell color to excel and now I think if I can read the gridview...
2
2516
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 in the view (like a report) but when a user wants to edit/insert items I'd like to show a different layout and different controls based on the selected item type. For example, for some items I'd like to provide text boxes and for others I'd like...
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.