ASP.NET Relay Element in Subclass

This is how I pull a field from my object:

However, how can I pull a field if it is in a subclass (Customer.ContactInfo.Name)?

+3
source share
3 answers

If you know that a DataItem is a specific type (let's say you know its type CustomerInfo), you can do this:

<%# ((CustomerInfo) Container.DataItem).ContactInfo.Name %>

As a bonus, this is somewhat faster than using DataBinder.Eval, because you avoid all overhead.

+8
source

Try ...

<%#((Customer)Container.DataItem).ContactInfo.Name%>
+3
source

Customer, :

+1

Source: https://habr.com/ru/post/1706046/


All Articles