Give Hex color code as a gridview background color
You need to assign a System.Drawing.Color
type. But you can easily get the instance from hex or named values like shown below:
Color clr = ColorTranslator.FromHtml("#FFFF33");
named colors:
Color clr = ColorTranslator.FromHtml("Red");
Also, you can directly specify the background/foreground color in the markup for gridview:
<asp:GridView ID="gridView1" Runat="server"
...
<RowStyle ForeColor="red" BackColor="#FFF7E7"></RowStyle>
</asp:GridView>
You can use both named and hex values.
xorpower
Reached 500 Repo on May 22'11 Reached 600 Repo on Jul 29'11 Reached 700 Repo on Aug 10'11 Reached 800 Repo on Sep 09'11 Reached 900 Repo on Oct 13'11 Reached (& crossed) 1000 Repo during Mar 14-19'12 Reached 1300 Repo on May 8 2013
Updated on June 04, 2022Comments
-
xorpower almost 2 years
How can I give an hex color code to gridview's row background color? I know that it is to be given on a
rowdatabound
event. But I am not sure whether a hex color code can be given or a default -System.Drawing.Color.(ColorName)
would only work?