473,657 Members | 2,530 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 = DataControlRowT ype.DataRow Then
If e.Row.Cells(0). Text = "1" Then
e.Row.Font.Bold = True
e.Row.Font.Ital ic = True
e.Row.ForeColor = Drawing.Color.D arkBlue
e.Row.Cells(1). Text = "  &n bsp;" & e.Row.Cells(1). Text
End If
End If

Thanks,

Keith
Apr 8 '08 #1
4 1845
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.ne twrote in message
news:uk******** ******@TK2MSFTN GP04.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 = DataControlRowT ype.DataRow Then
If e.Row.Cells(0). Text = "1" Then
e.Row.Font.Bold = True
e.Row.Font.Ital ic = True
e.Row.ForeColor = Drawing.Color.D arkBlue
e.Row.Cells(1). Text = "&nbsp;&nbsp;&n bsp;" & 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.EventArg s) 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********@gma il.comwrote in message
news:e6******** *************** ***********@e39 g2000hsf.google groups.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.EventArg s) 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
1730
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 with one acception: Currently, if the condition is met, and the field (B) becomes disabled, it retains the field value it had before it was disabled.
2
8938
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 color. These text boxes need to go behind a single line of other bound text boxes (which show the actual record). I.e., the purpose of the unbound text boxes w/conditional formatting is to highlight the record/background with one of six colors.
3
5928
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 terminated by pressing ++ and then terminate the process. I searched the entire internet and found out that there could be two things wrong (both of them are mentioned in the bug list on the access
4
3131
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 background colour. In A2000 it works great, but in A2003 the background doesn't always change and when it does it only changes when the record looses the focus. Any way around this? Is it a bug? Or have they "improved" it?
2
2345
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 on. I have a second table that contains a list of tasks to be performed and relates to the Case_List through a Case_ID. So currently, I can bring up a form that has a list of all my cases, I can then select a case and it opens a new form that...
8
8483
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 perfectly. However, I have code that runs under the ON CLICK event. The code changes the focus to other controls, which means the conditional formatting is no longer displayed. This part makes sense to me. Here's what doesn't make sense. The last...
4
13175
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 "No." The conditional formatting is set up to read the 'Yes' or 'No' value and color the text accordingly. I have an event in the subform that allows users to update the sales. It actually runs an update query behind the scenes. What I want to...
4
14408
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 can I use the custom colors I need ??? 2-Is Conditional Formatting available in code, so that I can use more than 3-conditions and have more versatility than the Access2k CF menu option offers ???
2
3109
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 day-fields is like WK (weekend), NH (National holiday), etc. Depending on the fieldvalue the field is colored using conditional
2
3289
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 current value, I set its background color. No problem with this part. My problem is that when clicking different text boxes representing the records on the continuous form, the left and the right margin areas do not always take on the background...
0
8413
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
8324
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
8842
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...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7352
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...
0
5642
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
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.