Asp.net gridview中特定于颜色的列
我所要做的就是将网格视图的最后三列设置为黄色。因为我在使用css,所以不能在boundfield中使用itemstyle吗?如果不是,我怎么能轻松做到这一点?谢谢Asp.net gridview中特定于颜色的列,asp.net,gridview,Asp.net,Gridview,我所要做的就是将网格视图的最后三列设置为黄色。因为我在使用css,所以不能在boundfield中使用itemstyle吗?如果不是,我怎么能轻松做到这一点?谢谢 <asp:GridView ID="grdMyProducts" DataSourceID = "srcGetMyProducts" CssClass="GridViewStyle" AutoGenerateColumns = "false"
<asp:GridView
ID="grdMyProducts"
DataSourceID = "srcGetMyProducts"
CssClass="GridViewStyle"
AutoGenerateColumns = "false"
AllowPaging = "false"
GridLines="None"
runat="server" >
<RowStyle CssClass="RowStyle" />
<EmptyDataRowStyle CssClass="EmptyRowStyle" />
<PagerStyle CssClass="PagerStyle" />
<SelectedRowStyle CssClass="SelectedRowStyle" />
<HeaderStyle Wrap="false" CssClass="HeaderStyleFilter" />
<EditRowStyle CssClass="EditRowStyle" />
<AlternatingRowStyle CssClass="AltRowStyle" />
<Columns>
<asp:BoundField
DataField="DistributorName"
HeaderText="Distributor" />
<asp:BoundField
DataField="Size"
HeaderText="Size" />
<asp:BoundField
DataField="Description"
HeaderText="Description" />
<asp:BoundField
DataField="Category"
HeaderText="Category" />
<ItemStyle BackColor="#f6f17c"/>
<asp:BoundField
DataField="Amount"
HeaderText="Amount" />
<ItemStyle BackColor="#f6f17c"/>
<asp:BoundField
DataField="Unit"
HeaderText="Unit" />
<ItemStyle BackColor="#f6f17c"/>
</Columns>
</asp:GridView>
UserItemStyle CSSClass边界字段的属性
<asp:BoundField DataField="Category" ItemStyle-CssClass="myStyle" HeaderText="Category" />
它应该会起作用。我测试过了。我觉得自己很愚蠢。。。。这是我代码中的一个错误。在调用项样式之前,我正在关闭绑定字段。这很有效。我上面的例子也可以,但代码中有一个错误。
.myStyle
{
background-color:Gray;
color:Red;
}