if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DateTime bookingdate = DataBinder.Eval(e.Row.DataItem, "bookingdate");
            if (bookingdate < DateTime.Now.Day())
                e.Row.BackColor = Color.Yellow;
        }
Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0266: Cannot implicitly convert type 'object' to 'System.DateTime'. An explicit conversion exists (are you missing a cast?)Source Error: Line 20:         if (e.Row.RowType == DataControlRowType.DataRow)
Line 21:         {
Line 22:             [color=#FF0000]DateTime bookingdate = DataBinder.Eval(e.Row.DataItem, "bookingdate");
Line 23:             if (bookingdate < DateTime.Now.Day())
Line 24:                 e.Row.BackColor = Color.Yellow;
 [/color]

解决方案 »

  1.   

    类型不能实现隐式转换,写成下面的试一下:
    DateTime bookingdate = DateTime.Parse(DataBinder.Eval(e.Row.DataItem, "bookingdate")); 
      

  2.   

    应该怎么解决他说我的     DateTime bookingdate = DataBinder.Eval(e.Row.DataItem, "bookingdate");  有问题~~我找不出~ 怎么理解呢
      

  3.   

    还是不行~说overload了~~~ Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1502: The best overloaded method match for 'System.DateTime.Parse(string)' has some invalid arguments
      

  4.   

    DateTime bookingdate = Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "bookingdate")); 
      

  5.   

    这次行了。不过说我的 if (bookingdate < DateTime.Now.Day())  有问题~~·
    我晕啊~~~DateTime.Now.Day())   就是当前日期,,因为怎么表示呢谢谢你了
      

  6.   

    试试:
    if (e.Row.RowType == DataControlRowType.DataRow) 
            {
                System.Data.DataRowView drv = (System.Data.DataRowView)e.Row.DataItem;            DateTime bookingdate = Convert.ToDateTime(drv["bookingdate"]);  // DataBinder.Eval(e.Row.DataItem, "bookingdate"); 
                if (bookingdate <  DateTime.Now.Date)      // DateTime.Now.Day()) 
                    e.Row.BackColor = Color.Yellow; 
            } 
      

  7.   

    这次对了~~是datatime.today 
    谢谢各位热心的对我这个超级笨的菜鸟帮助了~~
    真的谢谢各位了!!!