改变GridView某特定行的颜色

1、

<asp:GridView ID="GridView1" runat="server" HeaderStyle-VerticalAlign="Middle" AutoGenerateColumns="false" CssClass="gridview" HeaderStyle-HorizontalAlign="Center" OnRowDataBound="GridView1_RowDataBound">
</asp:GridView>



2、

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string cardName = DataBinder.Eval(e.Row.DataItem, "cardName").ToString();
            if (cardName == "总计")
            {
                e.Row.BackColor = System.Drawing.Color.Yellow;
                e.Row.ForeColor = System.Drawing.Color.Red;
            }
        }
    }


你可能感兴趣的:(改变GridView某特定行的颜色)