Change a control color in the aspx page

Usually, when I want to affect the appearance of an ASP.NET control, specifically a Telerik control, I'll trap the ItemDataBound event and get it there. 

But doing that involves a multi step process. I'm trying a new approach, changing it using my stored procedure and the aspx page. No code behind. 

The approach involves having a SQL field that specifies the color, and setting the FORECOLOR.

But...

This control will accept this

<telerik:RadButton  CssClass="Bold" ID="btnTakeoff" commandName="Takeoff" runat="server" Text='Takeoff' ForeColor='#FF0000' ></telerik:RadButton>

but not this

<telerik:RadButton  CssClass="Bold" ID="btnTakeoff" commandName="Takeoff" runat="server" Text='Takeoff' ForeColor='<%# Eval("buttoncolor") %>' ></telerik:RadButton>

It throws an invalid conversion error

Solution below

<telerik:RadButton  CssClass="Bold" ID="btnTakeoff" commandName="Takeoff" runat="server" Text='Takeoff'
        ForeColor='<%# System.Drawing.ColorTranslator.FromHtml(DataBinder.Eval(Container.DataItem, "TakeoffColor", "{0}")) %>' >
</telerik:RadButton>

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences