What's the difference between <#eval and <#bind in asp.net

前端 未结 7 824
天命终不由人
天命终不由人 2020-12-31 01:09

In a gridview, we can use <%#Eval%> or <%#Bind%> to output values from a database. What is the difference between them?

7条回答
  •  一整个雨季
    2020-12-31 01:54

    as they said Eval is one way and Bind is two way but one more important difference Bind must be assigned to a property of server side control (runat="server") while you can assign Eval to server side or client side control

    
        
             <%--you can do this--%>
             
             <%--you can do this--%>
             
             
    <%--WILL CAUSE AN ERROR--%> "<%#Bind('xx') %>" <%--you can do this--%> "<%#Eval('xx') %>"

提交回复
热议问题