473,795 Members | 3,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview Conditional Formatting ?

HI Guys,

I have bee using conditional formatting in the datagrid recently and I
am moving over to framework 2.0 and noticed the datagrid has been
replaced by the gridview. So, I would like to do conditional formatting
on the gridview but it doesnt have the same methods.

Currently in my datagrid I have this (this is just hacked together
randomly but gives you the idea):

Sub ItemDataBoundEv entHandler(ByVa l sender As Object, ByVal e As _
DataGridItemEve ntArgs)
Dim m As String = DataBinder.Eval (e.Item.DataIte m, "name")
If Trim(m) = "Euan" Then
e.Item.Cells(1) .BackColor = System.Drawing. Color.Yellow
e.Item.Cells(1) .Text = e.Item.Cells(1) .Text & "*"
End If
End Sub

But I would like to achieve something like that in gridview.

Further to that (if anyone knows), does anyone know how I could
intelligently detect the column number of the column "name" in
gridview?

This may seem like a stupid question but I am reasonably new to asp.net

Regards,
Euan

Nov 30 '05 #1
1 4577
Euan you can do the same for GridView read GridView Events
Go through this at:-
http://msdn2.microsoft.com/en-us/lib...us,VS.80).aspx
Patrick

<eu**@madprops. org> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
HI Guys,

I have bee using conditional formatting in the datagrid recently and I
am moving over to framework 2.0 and noticed the datagrid has been
replaced by the gridview. So, I would like to do conditional formatting
on the gridview but it doesnt have the same methods.

Currently in my datagrid I have this (this is just hacked together
randomly but gives you the idea):

Sub ItemDataBoundEv entHandler(ByVa l sender As Object, ByVal e As _
DataGridItemEve ntArgs)
Dim m As String = DataBinder.Eval (e.Item.DataIte m, "name")
If Trim(m) = "Euan" Then
e.Item.Cells(1) .BackColor = System.Drawing. Color.Yellow
e.Item.Cells(1) .Text = e.Item.Cells(1) .Text & "*"
End If
End Sub

But I would like to achieve something like that in gridview.

Further to that (if anyone knows), does anyone know how I could
intelligently detect the column number of the column "name" in
gridview?

This may seem like a stupid question but I am reasonably new to asp.net

Regards,
Euan

Dec 1 '05 #2

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

Similar topics

3
5936
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
3141
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?
8
12055
by: Dimitri Furman | last post by:
Given: Access 2002/2003 A subform in datasheet or continuous view, placed on a tab page (this last may or may not matter) Conditional formatting applied to some controls on the subform - format expressions are the same for all controls Under some undetermined circumstances, when such subform is displayed, the controls on the subform start to visibly flicker, the cursor in the subform stops blinking, and CPU utilization goes to 100%....
2
2966
by: Von Bailey | last post by:
I have a form where the conditional formatting is set on some fields to bold if certain conditions are met. However, when the conditions are met some of the data that is to bold is either not showing or only part of the data in the field displays (i.e. it will display the last name but not the first name or it will display neither). When the conditional formatting is removed it displays all the data as it should be display so the data...
1
5017
by: GGerard | last post by:
Hello Is there a way to use a variable in the Conditional Formatting of a Textbox? Example : I want the background of a textbox in a continuous form to change color when the value of "MyField1" is True. No problem, I just need to write "Expression is" and " = -1 "
2
5316
by: Jim in Arizona | last post by:
Using a GridView or other data reading control (gridview, datagrid, datalist), how can I do conditional formatting on the results pulled from an access database? As an exampe, use a sql statement to bind to the datagrid, and one of the columns has numerical data. How would I, say, make any data in that column that is over 1000 to be in red or bold? If this can't be done using one of these controls, how else would I get the job done? ...
8
8511
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
13201
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...
2
2420
by: tomh2099 | last post by:
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
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
10435
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...
1
10163
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
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9037
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
5436
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...
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.