My Gridview contains a lot of TemplateField.
I want every <td> in my html source to equal the color stored in my database
I am trying to execute code. Located below, but does not work, it gives me the <span> inside the <td> with my color, but it doesnโt appear in the browser
<asp:TemplateField HeaderText="BackGround Color"> <ItemTemplate> <asp:Label ID="lblBackColor" runat="server" BackColor='<%# ConvertFromHexToColor( Eval("BackColor").ToString()) %>'> </asp:Label> <itemstyle width="20%" horizontalalign="Center" /> </ItemTemplate> </asp:TemplateField>
C # code works
public Color ConvertFromHexToColor(string hex) { string colorcode = hex; int argb = Int32.Parse(colorcode.Replace("#", ""), NumberStyles.HexNumber); Color clr = Color.FromArgb(argb); return clr; }
And this is the html and css source code in my browser
<td> <span id="BodyZone__ThemesGrid_lblForeColor_0" style="background-color: #FFFFFF;"></span> <itemstyle width="20%" horizontalalign="Center"> </itemstyle> </td>
CSS
table.activity_datatable td { padding: 8px 15px; color: #6c6c6c; vertical-align: middle; -webkit-transition: all 0.2s; }
tito11
source share