Color Rows in Enterprise Portal AxGridView


  1. Create a new display method webBackgroundColor at InventTable

    public display Color webBackgroundColor()
            case ItemType::BOM:     return "Red";
            case ItemType::Item:    return "Green";
            case ItemType::Service: return "Blue";
            default: return "White";

  2. Create a new Dataset and add InventTable as DataSource
  3. Create or open a new Dynamcis Ax web project in Visual Studio
  4. Create or open an AxWebUserControl and add an AxDataSource using InventTable data set from AX
  5. Add an AxGridView and link it with the AxDataSource
  6. Add webBackroungColor**, ItemId and ItemName to the grid
  7. Select the AxGridView, change to events and modify the RowDataBound event

    protected void AxGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        string axColor = e.Row.Cells[0].Text.ToLower();
            e.Row.BackColor = System.Drawing.Color.Red;
        else if(axColor.Equals("green"))
            e.Row.BackColor = System.Drawing.Color.Green;
        else if(axColor.Equals("blue"))
            e.Row.BackColor = System.Drawing.Color.Blue;       

  8. Load the user control in an enterprise portal site

Use an Extended Datatype (Color instead of str) for the display method, otherwise you may experience strange behaviour in your ASP.NET application.