473,503 Members | 2,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

conditional grid formatting based on non-visible column

I have a gridview (asp.net 2.0) where I'm trying to format rows based on a
NON VISIBLE column. It doesn't seem to work. When column 0 below is visible,
the row is formatted as expected but when it's not, it doesn't do anything.
How can I do this so that the formatting is based on the value of a
non-visible column?

If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.Cells(0).Text = "1" Then
e.Row.Font.Bold = True
e.Row.Font.Italic = True
e.Row.ForeColor = Drawing.Color.DarkBlue
e.Row.Cells(1).Text = "   " & e.Row.Cells(1).Text
End If
End If

Thanks,

Keith
Apr 8 '08 #1
4 1839
Are you doing this on postback? Non-visible controls don't come back in
postbacks. A good place for non-visible values is DataKeys collection.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Keith G Hicks" <kr*@comcast.netwrote in message
news:uk**************@TK2MSFTNGP04.phx.gbl...
>I have a gridview (asp.net 2.0) where I'm trying to format rows based on a
NON VISIBLE column. It doesn't seem to work. When column 0 below is
visible,
the row is formatted as expected but when it's not, it doesn't do
anything.
How can I do this so that the formatting is based on the value of a
non-visible column?

If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.Cells(0).Text = "1" Then
e.Row.Font.Bold = True
e.Row.Font.Italic = True
e.Row.ForeColor = Drawing.Color.DarkBlue
e.Row.Cells(1).Text = "&nbsp;&nbsp;&nbsp;" & e.Row.Cells(1).Text
End If
End If

Thanks,

Keith


Apr 8 '08 #2
It looks like he's doing it on the RowDataBound. If that's the case,
and the hidden column is the problem, you could wait until the Page's
PreRender event to hide the column.

Apr 8 '08 #3
Hmm.. that worked for me. I tested your scenario. You're right, it
doesn't work when the column is hidden. So I made it visible on the
client side, and hid the column like so on the server side:

Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
Me.grd.Columns(1).Visible = False
End Sub

In this case, the grid was formatted correctly. You have to make sure
the formatting happens before hiding the column. So, if you're
formatting in RowDataBound you can hide the column in PreRender. You
can verify this yourself by putting stops on each of the events.
(Click in the gray to the left of the line number.)

Try it again. Make sure you close your debugger instance before
verifying. I don't know how many times I've been trying to figure
something out and simply closing the browser window and re-opening it
helped.
Apr 8 '08 #4
OK. Thanks for the info. I'll test your suggestion. I'm sure it will work
fine.

Keith

<Po********@gmail.comwrote in message
news:e6**********************************@e39g2000 hsf.googlegroups.com...
Hmm.. that worked for me. I tested your scenario. You're right, it
doesn't work when the column is hidden. So I made it visible on the
client side, and hid the column like so on the server side:

Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
Me.grd.Columns(1).Visible = False
End Sub

In this case, the grid was formatted correctly. You have to make sure
the formatting happens before hiding the column. So, if you're
formatting in RowDataBound you can hide the column in PreRender. You
can verify this yourself by putting stops on each of the events.
(Click in the gray to the left of the line number.)

Try it again. Make sure you close your debugger instance before
verifying. I don't know how many times I've been trying to figure
something out and simply closing the browser window and re-opening it
helped.

Apr 8 '08 #5

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

Similar topics

0
1725
by: Tim Graichen | last post by:
Hello, I am using the built-in conditional formatting tool in Access 2000 to disable a field (B) in my form based on the condition of another field (A) in the same form. This all works fine...
2
8908
by: John Kreps | last post by:
(acc 2002) I've got six unbound text boxes on a subform that has a white background. Each of those six boxes has an expression that when true, will change its background from white to another...
3
5918
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
4
3114
by: Bradley | last post by:
I have an A2000 database in which I have a continuous form with a tick box. There is also a text box with a conditional format that is based on the expression , if it's true then change the...
2
2335
by: jodyblau | last post by:
I'm not certain that what I am trying to do is possible; in any event I haven't been able to figure it out. Here is what I am trying to do: I have one table that has a list of cases I'm working...
8
8461
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
4
13099
by: midlothian | last post by:
Hello, I have conditional formatting set up on a subform based on a calculated value in the underlying query. For instance, if Sales are >$1000, the query displays "Yes," otherwise it displays...
4
14378
by: ApexData | last post by:
In a Continuous form, I want to use Conditional Formatting to change the background color of a date field based on a condition. 1-The color chart in the CF menu option offers limited colors. How...
2
3103
by: Filips Benoit | last post by:
Dear All, Access 2003 adp on SQL_server 2005 A continious form showing 1 month based on table 'CALENDAR_MONTH_GRID' and fill with a SP. Fields: Companyname, Day1, day2, etc. The value in the...
2
3269
by: robertng90025 | last post by:
I'm having a problem with MS Access 2003 and its conditional formatting. I have textboxes on a continuous form whose left and right margins are set to 0.03 inches. Based on each textbox's...
0
7207
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
7093
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
7357
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...
1
7012
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
7468
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...
0
5598
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,...
1
5023
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...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.