I have my custom control inside of a formview. This custom control has a variety of properties one of which is Value
which I am trying to databind.
Using Container.DataItem
I can databind my control, and everything works:
<fc:Literal runat="server" ID="readState" Label="State:" Value='<%# Container.DataItem("ActivityState") %>' />
Then when I try to databind using Eval
, then it doesn't:
<fc:Literal runat="server" ID="readState" Label="State:" Value='<%# Eval("ActivityState") %>' />
Gives the Error:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Everything workds great with Container.DataItem
, so my question is: Why does Container.DataItem
work and Eval
doesn't?