2010-03-10 141 views

回答

1

它只会将.Eval方法返回的对象转换为DateTime类型。如果不能施法,则会抛出InvalidCastException。关于你可以放在DataBinder.Eval前面的功能,你可以放任何东西。但是,大多数这不起作用。

1

这是铸造数据从object其中Eval正在返回到DateTime

// If the cast fails you will get an exception 
DateTime dt = (DataTime)(DataBinder.Eval("yourfield")); 

// If the cast fails you will get null. 
DateTime? dt = DataBinder.Eval("yourfield") as DateTime?; 

// You could also do which will throw an exception if it fails as well. 
DateTime dt = Convert.ToDateTime(DataBinder.Eval("yourfield")); 

有关转换更多信息,请MSDN

相关问题