Setting table cell color from database

I think about it. I have colors stored in a database table and I want to set the background of specific cells in the table for those colors. In other words:

<table>
    <tr>
        <td ???set color here???>
            ...content...
        </td>
        <td ???next color here???>
            ...next content...
        </td>
    </tr>
</table>

      

Initially, I had panels surrounding each piece of content, and I set their background color in code, which worked great until I had different size panels that discarded the layout. What's the simplest way to pass color values ​​from the database to an item <td>

? Please note that the colors are user configurable, so I cannot foresee them in the CSS file.

0


source to share


4 answers


You can create your own CSS file with database data by creating a custom HttpHandler.
But the easy way is:

<td style="background-color:#000000">
...
</td>

      



from

<td style='background-color:<%= GetCellColor() %>'>
...
</td> 

      

+7


source


Why not populate a CSS DB?



.dark {
   background-color:[database field]
}

<td class='dark'></td>

      

0


source


Is this a table with a fixed number of rows / columns?

You can use ASP code here. td backcolor = "<% = MyColorProvider.FirstCellColor%>" .....

Where MyColorProvider.FirstCellColor is the string representation of the color (it can also be a hex string).

0


source


You can dump the css file from the database when you start your application and then include the css file on the master page.

0


source







All Articles