我有一个在特定条件下修改 CSS 的 GridView。在开发中工作正常,但似乎无法在服务器上执行。
.net 4.0
想法?
网格视图:
GridView ID="gridViewCalendar" runat="server"
AutoGenerateColumns="False"
CssClass="calendarGrid"
OnRowDataBound="GridViewCalendar_RowDataBound">
代码背后
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
{
gridViewCalendar.DataBind();
}
}
protected void GridViewCalendar_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string b0field = e.Row.Cells[0].Text;
string b1field = e.Row.Cells[1].Text;
if (b0field == " ")
{
e.Row.Cells[0].BackColor = Color.FromName("#C0C0C0");
e.Row.Cells[1].BackColor = Color.FromName("#C0C0C0");
}
else if (b1field != " ")
{
e.Row.CssClass = "calendarNormal";
}
else
{
e.Row.CssClass = "calendarBold";
}
}
}
谢谢