Monday, May 19, 2008

Change GridView backgrod color

aspx

< id="grdLicensedClients" runat="server" onrowdatabound="grdLicensedClients_RowDataBound">

c#

protected void grdLicensedClients_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drv = (DataRowView)e.Row.DataItem;

string areaCode = drv["Area"].ToString();

if (_duplicateAreaCodes.Contains(areaCode))
{
e.Row.BackColor = System.Drawing.Color.Yellow;
}
}
}

No comments: