Answered by:
DataBinder.Eval

Question
-
User2024669276 posted
guys i am a little new here, hence pls bear with me if its really simple and i dont get it. i am reading an aspx page and it has Databinder.Eval expressions. Below are the types i am seeing, can you please explain me the meaning of these. Also, can we have these expressions without having a datasource property set for the databound controls such as gridview, datalist etc.
a. <%# DataBinder.Eval(Container, "DataItem.xyz")%> b. <%# DataBinder.Eval(Container.DataItem, "xyz") %>
Friday, July 1, 2011 6:20 PM
Answers
-
User-843484705 posted
It might solve your problem
http://weblogs.asp.net/jgalloway/archive/2005/09/20/425687.aspx
http://stackoverflow.com/questions/1178863/whats-the-difference-between-databinder-eval-and-container-dataitem
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, July 2, 2011 2:55 PM
All replies
-
User-1161841047 posted
DataBinder.Eval Method evaluates data-binding expressions at run time. This method contain two/ three parameters. the first one is the container(DataSource) the container shoud be Container.DataItem if you are use GridView,datalist ... .The second parameter is the field of the public property from the container.
Sure you need datasource to binding against databinding controls ( GridView ,datalist ...).
Saturday, July 2, 2011 2:06 AM -
User2024669276 posted
i understand this. But whats the difference between the two lines that i have mentioned in point a and b.
Saturday, July 2, 2011 2:40 PM -
User-843484705 posted
It might solve your problem
http://weblogs.asp.net/jgalloway/archive/2005/09/20/425687.aspx
http://stackoverflow.com/questions/1178863/whats-the-difference-between-databinder-eval-and-container-dataitem
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, July 2, 2011 2:55 PM -
User-1161841047 posted
As I mentioned before the Container.DataItem used with list Web Controls such as GridView,Datalsit, Repeater.... On the other hand if you binding against the page , then container should be the page.
For more information find Page.DataBind() versus Control.DataBind().
Saturday, July 2, 2011 3:27 PM -
User2024669276 posted
thanks prince. this helps.
Saturday, July 2, 2011 7:15 PM