Jump to content
Software FX Community

Format data in one column based on values in another column


RDiehl

Recommended Posts

Posted

I'm looking for something at page load/data bound that sets text or background color in a target column based on the value in another column. In one post I saw a suggestion on iterating items 'on data bound' to apply format but I need something more specfic.

Posted

Try a different event, like Grid Rendering:

protected void Grid1_Rendering(object sender, EventArgs e)

  {

  try

  {

  Color RedColor = Color.Red;

  Color BlueColor = Color.Blue;

  foreach (GridItem Item in Grid1.Items)

  {  

  if (Convert.ToDouble(Item.Cells[0].Text) < 5)

  {

  Item.Style.BackColor = RedColor;

  }

  else

  {

  Item.Style.BackColor = BlueColor;

  }

  }

  }

  finally

  {   }

  }

Let me know if this helps.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...