Did you ever get a message "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control" while binding a databound control ?
If you ask me this question, my answer is Yes, i did receive the above message when i tried binding a dropdownlist template column inside the gridview control in asp.net 2.0. I was surprised seeing the message hitting me all the rack and was curious to see the issue in detail.
I had already done the binding of template column (drop down) in the row item created event.
Upong further investigarion i came to know that there is a difference between <%#Eval("field_name") %> and <%# Databinder.Eval("filed_name") %>
In the Eval(), ASP.net resolves the object to which databinding is done where as in the Databinder.Eval() since we give the target object manually, ASP.net has nothing to resolve.
So the resolution is use <%# Databinder.Eval("filed_name") %> instead <%# Eval("field_name") %>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment