Thursday, July 24, 2008

OnRowDataBound gridview conditional formatting C#

How To Show Some Rows Differently in a GridView SimplyGold




protected void CustomerGrid_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
GridViewRow row = e.Row;

// Make sure we aren't in header/footer rows
if (row.DataItem == null)
{
return;
}

Customer customer = row.DataItem as Customer;

if (/* Do your conditionals here*/)
{
// Change Row formatting here OR
// Add new cells
// Or create an entirely different cells
}
}

www.visli.com

No comments: