Using DataBinder for casting the whole object in one step
Is it possible to cast the whole object using DataBinder.Eval()
instead of casting it by property. e.g.:
// instead of this
var p = new Person();
p.FirstName = Convert开发者_如何学Python.ToBoolean(DataBinder.Eval(Container.DataItem, "FirstName"));
p.Age = Convert.ToInt32(DataBinder.Eval(Container.DataItem, "Age"));
...
// use something like this in one step
var p = DataBinder.Eval<Person>(Container.DataItem);
精彩评论