我在 GridView 中显示学生出勤率。
我选择缺席为A,出席为P,离开为L。现在我想用红色显示A,用绿色显示P。
怎么样。请帮助我
请您参考如下方法:
请试试这个,让我知道你遇到了什么问题
protected void grdStudent_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRow dr = ((DataRowView)e.Row.DataItem).Row;
if (dr["Present"].ToString() == "A")
{
((Label)e.Row.FindControl("yourLableID")).ForeColor= System.Drawing.Color.Red;
//yourLableID is that lable in which you are showing A or P
}
}
}
