The best way, of course, is to convert the method to a property. But I can't do that here --
We have an API from someone else, and we've added an extension method to one of the objects. We need at the string this method returns in a data-binding situation (a GridView).
It doesn't seem that we can add an extension property (man, that would have been really nice...), so I have this method, and I want the cleanest way possible to render it in data-binding:
While I can do this with a property:
<%# Eval("MyProperty") %>
I have to do this with a method:
<%# ((MyClass)Container.DataItem).MyExtensionMethod() %>
This is how I've done it in the past, but is there a cleaner way than that? I can't change the class (it's not mine), and I can't add an extension property, so I'm stuck with this method.