Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net gridview中特定于颜色的列_Asp.net_Gridview - Fatal编程技术网

Asp.net gridview中特定于颜色的列

Asp.net gridview中特定于颜色的列,asp.net,gridview,Asp.net,Gridview,我所要做的就是将网格视图的最后三列设置为黄色。因为我在使用css,所以不能在boundfield中使用itemstyle吗?如果不是,我怎么能轻松做到这一点?谢谢 <asp:GridView ID="grdMyProducts" DataSourceID = "srcGetMyProducts" CssClass="GridViewStyle" AutoGenerateColumns = "false"

我所要做的就是将网格视图的最后三列设置为黄色。因为我在使用css,所以不能在boundfield中使用itemstyle吗?如果不是,我怎么能轻松做到这一点?谢谢

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