GridView Highlight Certain Rows

S

-Steve-

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?
 
S

Sergio E.

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.
 
M

marss

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top