473,401 Members | 2,068 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,401 software developers and data experts.

GridView Highlight Certain Rows

I have the need to change the text of certain rows to red based on the
proximity of a date in one of the columns. What's the best way to go about
this?
Sep 12 '07 #1
2 1400
On 12 , 09:18, "-Steve-"
<n...@dosomethingwiththis.miisconsultant.comwrot e:
I have the need to change the text of certain rows to red based on the
proximity of a date in one of the columns. What's the best way to go about
this?
Add RowDataBound event handler.
Within this handler you can access data though e.Row.DataItem and
GridView row though e.Row.
Something like this:
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
DataRow dataRow = e.Row.DataItem as DataRow;
DateTime dt = dataRow["DataColumn"] as DateTime;
if (...)
e.Row.BackColor = System.Drawing.Color.Red;
}

Regards,
Mykola
http://marss.co.ua

Sep 12 '07 #2
write code in the rowdaatbound event of the gridview
some like
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
if e.Row.RowType=DataControlRowType.DataRow then
Dim drv As DataRowView = CType(e.Row.DataItem, DataRowView)
if(drv("namecolumnX")="flag1" then
e.row.cssclass="csshighlight"
endif
endif
end sub

hope this works for you

greetings,
Sergio E.
"-Steve-" <nn**@dosomethingwiththis.miisconsultant.comescrib ió en el
mensaje news:uN**************@TK2MSFTNGP03.phx.gbl...
>I have the need to change the text of certain rows to red based on the
proximity of a date in one of the columns. What's the best way to go about
this?

Sep 12 '07 #3

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

Similar topics

7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
3
by: VMI | last post by:
How can I select a row in a Web gridview? I added a ButtonField to my gridview, but I'm not certain what other properties I should change in order for the row to be highlighted. I also changed the...
1
by: Marc Pavo | last post by:
Since Ajax.net isn't production-worthy yet, I'm looking for any info on this (as well as manipulating GridView from client script in general). Thank you!
11
by: Greg | last post by:
I have a gridview on my form which I have populated using a datareader. What I would like to do is to be able to remove specified records from the gridview, without affecting the source of the...
2
by: rohitscripts | last post by:
i have a gridview in my web page which shows the details like employee name, employee salary. i filled my gridview using a dataset and all the values are retrieved from sqlserver db. now, in my...
2
by: bernard.oflynn | last post by:
I'm not sure if there is a way to do this...I have data coming back in rows for various currencies. I need to split out the data in a GridView so that all the rows for one currency appears in that...
2
by: DC | last post by:
Hi, I am using a GridView to present data in a DataTable, which I store only in ViewState and when the user hits the "OK" button the rows in the DataTable will be used to execute transactions. ...
2
by: Michael | last post by:
It seems that a gridview allows us to delete only a single row at a time. How to extend this functionality to select multiple rows and delete all of the selected rows in a single stroke? just like...
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: 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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...
0
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,...

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.