I’ve got a grid view where I am trying to set the fore color from a database string which contains HTML Code. I tried this:
<asp:TemplateField HeaderText="Validation">
<ItemTemplate>
<asp:Label ID="lblValidationItem" runat="server" ToolTip="Type of validation."
Text='<%# DataBinder.Eval(Container, "DataItem.ValidationItem") %>' Font-Bold="true" ForeColor='<%# System.Drawing.ColorTranslator.FromHtml(Eval("HTMLColor")) %>'></asp:Label>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
But it says FromHtml has some invalid parameters?
Eval returns an “Object”. You need to cast it to a string: