locked
How do you dynamically set the cell color in an ASP DataGrid? RRS feed

  • Question

  • User-118722192 posted
    Hi,

    I have an ASP page that was built using MS Visual InterDev.  The original programmer used the MS Visual InterDev DataGrid control to render his recordset.  What I need to do is to change one of the cell colors based on a database value.  Right now the code looks like this:

    function _Grid1_ctor()
    {
        CreateDataGrid('Grid1',_initGrid1);
    }

    function _initGrid1()
    {
    if (Session("HaveFoodGroup") == true)
        {
        Grid1.colHeader[1] = '"Food Group"';
        Grid1.colData[1] = 'get_foodgroup()';
        }
    }

    function get_foodgroup()
    {
     var stemp = Recordset1.fields.getValue("foodGroup");
     return stemp;
    }

    }

    The problem is I need to know what the value of get_foodgroup() is prior to assigning it to Grid11.colData[1].  I tried calling get_foodgroup() in _initGrid1() prior to assigning it to Grid1.colData[1] but got a bunch "undefined" messages in the cell.  Any ideas?

    Thanks

    Wednesday, April 27, 2005 11:47 AM

All replies