Has anyone successfully used extension methods in data binding expressions?
Let's say I have an extension method called "GetName" attached to "MyClass".
In the code behind, I confirmed that this works:
MyClass myObject = new MyClass();
MyClass.GetName();
However, in a web form, I try this:
<%@ Import Namespace="My.Namespace" %>
Then in the Repeater ItemTemplate:
<%# ((MyClass)Container.DataItem).GetName() %>
Visual Studio is cool, Intellisense agrees with everything, and the project is under construction. But when I run it, I get:
Compilation error
"My.Namespace.MyClass" does not contain a definition for "GetName"
Thus, the code-code will take the extension method, but not the web form. I suspect this is a problem with names, but I imported the same namespace in both places.