OnRowDatabound方法不执行

时间:2013-02-08 00:41:36

标签: c# .net

我有一个在某些条件下修改CSS的GridView。在开发中工作正常但似乎不在服务器上执行。

.net 4.0

想法?

GridView的:

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

由于

0 个答案:

没有答案