Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

GridView Highlight Certain Rows

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
-Steve- - 12 Sep 2007 07:18 GMT
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?
Sergio E. - 12 Sep 2007 07:37 GMT
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.

>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?
marss - 12 Sep 2007 07:38 GMT
On 12    , 09:18, "-Steve-"
<n...@dosomethingwiththis.miisconsultant.com> wrote:
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.