如何在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;
}