bemara57
asked on
What's the difference between DataBinder.Eval and Bind?
I'm binding object properties to a GridView via the aspx page instead of the code-behind. I'm having trouble understanding the difference between DataBinder.Eval and Bind because they seem to do the same thing. Below is what I have in a web app. What caught my attention is that this wouldn't compile (parse error). Notice the dot notation of the object property Depth:
<asp:Literal ID="productDimensionsDepth " runat="server"
Text='<%# Bind("Dimensions.Depth") %>' />
But when I changed it like this, it worked fine:
<asp:Literal ID="productDimensionsWidth " runat="server"
Text='<%# DataBinder.Eval(Container. DataItem, "Dimensions.Width") %>' />
How come there is a difference? Are these identical?
<asp:Literal ID="productName" runat="server"
Text='<%# Bind("Name") %>' />
<asp:Literal ID="productName" runat="server"
Text='<%# DataBinder.Eval(Container. DataItem, "Name") %>' />
<asp:Literal ID="productDimensionsDepth
Text='<%# Bind("Dimensions.Depth") %>' />
But when I changed it like this, it worked fine:
<asp:Literal ID="productDimensionsWidth
Text='<%# DataBinder.Eval(Container.
How come there is a difference? Are these identical?
<asp:Literal ID="productName" runat="server"
Text='<%# Bind("Name") %>' />
<asp:Literal ID="productName" runat="server"
Text='<%# DataBinder.Eval(Container.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.