Sunday, March 11, 2012

Getting System.Web.UI.Control does not contain a definition for DataItem error on controls

Hmm this is indeed one of the weirdest bugs I've ever seen. Not the weirdest, but it's up there!

I can't for the life of me figure out why it's breaking (at least, not the real root cause). However, if you use the "simplified databinding" feature of ASP.NET 2.0 then it works. Just replace calls to DataBinder.Eval(Container.DataItem, "...") with calls to Eval("...") and then it works.

For example: <asp:Label ... Text='<%# Eval("name") %>' />

Thanks,

Eilon


That works fine, I guess it's probably better anyway from what I can gather (still getting up to speed on asp.net 2.0 from 1.1).

Thanks!

No comments:

Post a Comment