Has anyone successfully used extension methods in data-binding expressions?
Say I have an extension method called "GetName" attached to "MyClass".
In the code behind, I have verified this works:
MyClass myObject = new MyClass();
MyClass.GetName();
However, in a Web form, I try this:
<%@ Import Namespace="My.Namespace" %>
Then, in the ItemTemplate of a Repeater:
<%# ((MyClass)Container.DataItem).GetName() %>
Visual Studio is cool with this, Intellisense agrees with everything, and the project builds. But when I run it, I get:
Compilation Error
'My.Namespace.MyClass' does not contain a definition for 'GetName'
So, the code-behind will accept the extension method, but not the Web form. I suspect it's a name-spacing issue, but I've imported the same namespace in both places.