子类中的ASP.NET Repeater项

Mik*_*ole 3 asp.net repeater

这是我如何从我的对象中拉出一个字段:

但是,如果字段位于子类(Customer.ContactInfo.Name)中,如何提取字段?

Kel*_*tex 8

如果您知道DataItem是某种类型(假设您知道它是CustomerInfo类型),您可以这样做:

<%# ((CustomerInfo) Container.DataItem).ContactInfo.Name %>
Run Code Online (Sandbox Code Playgroud)

作为奖励,它比使用DataBinder.Eval快一些,因为你避免了所有的反射开销.