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