views:

331

answers:

1

So I have an IList of business entities that I loop through in a ListView into an unordered list. I created an extension method on this Entity in my presentation layer. In code behind, I can Response.Write the result of this extension method, but when I try to access it through the ListView I get an error. The method is called IsCurrent and returns a bool... Here is my code:

<li><%#((CB.CMSFramework.WebPage)Container.DataItem).IsCurrent(Guid.Empty) %></li>

The error I get is: 'CB.CMSFramework.WebPage' does not contain a definition for 'IsCurrent' and no extension method 'IsCurrent' accepting a first argument of type 'CB.CMSFramework.WebPage' could be found (are you missing a using directive or an assembly reference?)

However... I get no error when I do this type of code from code behind:

WebPage w = new WebPage();
Response.Write(w.IsCurrent(Guid.Empty));
+1  A: 

Your page needs to @Import the namespace containing the extension method

TheSoftwareJedi
OMG. I can't believe it. You'd think that namespace would be in scope (I have it at the same namespace level as the page itself). OY. Thank you.
EvilSyn
@EvilSyn Get R# and this won't happen again. :) http://www.jetbrains.com/resharper/
bzlm