Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Dear All,

How to change the Header text color in Asp.net Gridview Design.

Please help

Thanks in Advance.


This is my Gridview Design code.
ASP.NET
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
 BackColor="#DEBA84" BorderStyle="None" CellPadding="3" 
CssClass="gv1" HorizontalAlign="Center" 
                                                onpageindexchanging="GridView1_PageIndexChanging" 
onprerender="GridView1_PreRender" onrowdatabound="GridView1_RowDataBound" 
                                                onselectedindexchanged="GridView1_SelectedIndexChanged" 
onsorting="GridView1_Sorting" PageSize="30" Width="1060px" 
BorderColor="#DEBA84" BorderWidth="1px" CellSpacing="2">
<pagersettings firstpagetext="First" lastpagetext="Last">
 Mode="NumericFirstLast"/>
      <rowstyle backcolor="#FFF7E7" forecolor="#8C4510" />
                                                <columns>
                                                    <asp:CommandField meta:resourcekey="CommandFieldResource1" 
                                                        ShowSelectButton="True" />
                                                </columns>
                                                <footerstyle backcolor="#F7DFB5" forecolor="#8C4510" horizontalalign="Right" />
                                                <HeaderStyle BackColor="#A55129" Font-Bold="True" Font-Size="12px" 
                                                    ForeColor="White" Height="30px" />
                                                <pagerstyle cssclass="cssPager" forecolor="#8C4510" horizontalalign="Right" />
                                                <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
                                                <emptydatatemplate>
                                                    Sorry, No Records Found
                                                </emptydatatemplate>
                                            </pagersettings>
Posted
Updated 24-Aug-12 20:54pm
v2

 
Share this answer
 
I use it for my case..hope it can help you..
XML
<asp:GridView ID="GridView1" CssClass="listStyle" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="courseNo">

        <Columns>

            <asp:BoundField DataField="courseTitle" HeaderText="Course Title" HeaderStyle-ForeColor="Maroon" HeaderStyle-BackColor="#ffb8a6"
                SortExpression="courseTitle"  ReadOnly="True"/>

            <asp:BoundField DataField="courseDescription" HeaderText="Description" HeaderStyle-ForeColor="Maroon" HeaderStyle-BackColor="#ffb8a6"
                SortExpression="courseDescription" />

            <asp:BoundField DataField="courseCredit" HeaderText="Credit" HeaderStyle-ForeColor="Maroon" HeaderStyle-BackColor="#ffb8a6"
                SortExpression="courseCredit" />

        </Columns>
    </asp:GridView>
 
Share this answer
 
have You used external css?
if yes then check th, td color property is'nt set in css ?

or
try this
XML
<asp:TemplateField  ItemStyle-Height ="10px">
                                                                   <ItemTemplate>

                                                                        <asp:CommandField meta:resourcekey="CommandFieldResource1" 
                                                        ShowSelectButton="True" />
                                                                   </ItemTemplate>
                                                                       <HeaderStyle HorizontalAlign="Left" CssClass="HeaderStyle1"  />
                                                                           <ItemStyle Width="10px"  />
                                                           </asp:TemplateField>

and in css
CSS
td.HeaderStyle1
{

    text-decoration:none;
    color:#ffffff;
   /* display:block;*/
 /*text-align:center;*/
    font-weight:bold;
    font-size:12px;
    /*padding: 5px; */
   height:30px;
    border :0px;
}
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900