Last post Jul 02, 2011 07:15 PM by flopdix
Jul 01, 2011 06:20 PM|flopdix|LINK
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") %>
Jul 02, 2011 02:06 AM|Yousef_Jadallah|LINK
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 ...).
Jul 02, 2011 02:40 PM|flopdix|LINK
i understand this. But whats the difference between the two lines that i have mentioned in point a and b.
Jul 02, 2011 02:55 PM|princeG|LINK
It might solve your problem
Jul 02, 2011 03:27 PM|Yousef_Jadallah|LINK
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().
Jul 02, 2011 07:15 PM|flopdix|LINK
thanks prince. this helps.