【问题标题】:BoundField styleBoundField 风格
【发布时间】:2011-06-05 03:12:03
【问题描述】:

如何为 BoundField 赋予样式?

我在 Gridview 中使用 BoundField。 Tt 显示下划线和不需要的颜色。

如何去除下划线和颜色?

【问题讨论】:

    标签: asp.net gridview boundfield


    【解决方案1】:

    根据您尝试的绑定字段,它可能会有所不同,但这里是一个示例。每个字段都有各种样式的属性,您也可以设置CssClass

    命令字段

    .select {
        text-decoration: none;
        color: Red;
    }
    
    <asp:CommandField ShowSelectButton="True">
        <ControlStyle CssClass="select" />
    </asp:CommandField>
    

    绑定字段

    .product {
        color: Blue;
    }    
    
    <asp:BoundField DataField="ProductName" HeaderText="Product Name" ItemStyle-CssClass="product">
        <ItemStyle CssClass="product" />
    </asp:BoundField>
    

    转到GridView 属性→ 列,您会发现那里列出了所有字段。在那里你可以设置style properties of BoundField.

    另一种选择是使用模板字段,您将拥有更多控制权。

    【讨论】:

    • ItemStyle-CssClass 为我工作,谢谢。我正在使用 ControlStyle-CssClass。
    猜你喜欢
    • 2011-03-27
    • 2011-11-21
    • 2015-03-04
    • 2010-11-25
    • 2018-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多