如何在Asp.net Gridview设计中更改标题文本颜色 [英] How to change the Header text color in Asp.net Gridview Design

查看:141
本文介绍了如何在Asp.net Gridview设计中更改标题文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

如何在Asp.net Gridview Design中更改页眉文本颜色.

请帮忙

在此先感谢.


这是我的Gridview设计代码.

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: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>

推荐答案

参考:

http://msdn.microsoft.com/en-us/library/aa479342.aspx [ ^ ]
Refer:

http://msdn.microsoft.com/en-us/library/aa479342.aspx[^]


我将其用于我的情况..希望它可以为您提供帮助..
I use it for my case..hope it can help you..
<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>


您使用过外部CSS吗?
如果是,则检查th,在CSS中未设置td color属性?


试试这个
have You used external css?
if yes then check th, td color property is''nt set in css ?

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

                                                                        <asp:CommandField meta:resourcekey="CommandFieldResource1" 

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


并在CSS中


and in 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;
}


这篇关于如何在Asp.net Gridview设计中更改标题文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆