In this article I will explain with examples, the difference between Eval and Bind functions in ASP.Net.
Eval and Bind functions are used to bind data from database to controls present inside DataBound controls like GridView, DetailsView, Repeater, DataList, etc.
 
 
The Difference
The difference between Eval and Bind is that Eval function is used to bind data to control inside a DataBound control, but it cannot update the values back to the database.
On the other hand, Bind function can be used to bind data to control inside a DataBound control and also it can update the values back to the database.
But the above explanation did not give me clear idea and hence I wrote two examples in order to illustrate the functioning Eval and Bind functions in ASP.Net.
 
 
Database
I have made use of the following table Customers with the schema as follows.
Bind (Populate) ASP.Net DropDownList using DataTable (DataSet) in C# and VB.Net
I have already inserted few records in the table.
Bind (Populate) ASP.Net DropDownList using DataTable (DataSet) in C# and VB.Net
 
Note: You can download the database table SQL by clicking the download link below.
          Download SQL file
 
 
The Eval function
The following HTML Markup consists of an ASP.Net GridView consisting of TextBoxes inside TemplateField column of GridView and a SqlDataSource specified with a SelectCommand.
This is an ideal example of Eval function as here the main objective is to display data and no Insert or Update operation is required.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" DataSourceID="SqlDataSource1" DataKeyNames="CustomerId" Width="180">
    <Columns>
        <asp:TemplateField HeaderText="Name" ItemStyle-Width="80">
            <ItemTemplate>
                <asp:TextBox ID="txtName" runat="server" Text='<%# Eval("Name") %>' />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Country" ItemStyle-Width="100">
            <ItemTemplate>
                <asp:TextBox ID="txtCountry" runat="server" Text='<%# Eval("Country") %>' />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:constr %>" SelectCommand="SELECT CustomerId, Name, Country FROM Customers"></asp:SqlDataSource>
 
The following screenshot displays the GridView consisting of TextBoxes whose values are populated using Eval function.
Difference between Eval and Bind functions in ASP.Net
 
 
The Bind function
The following HTML Markup also consists of a GridView and SqlDataSource, but there are three differences.
1. Bind function has been used to populate TextBoxes instead of Eval.
2. The SqlDataSource is specified with an UpdateCommand.
3. There’s an additional column consisting of a LinkButton for updating the GridView.
In the below GridView, if you modify a TextBox value and click Update then the value will also be updated in the database.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" DataSourceID="SqlDataSource1" DataKeyNames="CustomerId">
    <Columns>
        <asp:TemplateField HeaderText="Name" ItemStyle-Width="150">
            <ItemTemplate>
                <asp:TextBox ID="txtName" runat="server" Text='<%# Bind("Name") %>' />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Country" ItemStyle-Width="150">
            <ItemTemplate>
                <asp:TextBox ID="txtCountry" runat="server" Text='<%# Bind("Country") %>' />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="" ItemStyle-Width="100">
            <ItemTemplate>
                <asp:LinkButton Text="Update" runat="server" CommandName = "Update" />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:constr %>"
    SelectCommand="SELECT CustomerId, Name, Country FROM Customers"
    UpdateCommand="UPDATE Customers SET Name = @Name, Country = @Country WHERE CustomerId = @CustomerId">
    <UpdateParameters>
        <asp:Parameter Name="CustomerId" Type="Int32" />
        <asp:Parameter Name="Name" Type="String" />
        <asp:Parameter Name="Country" Type="String" />
    </UpdateParameters>
</asp:SqlDataSource>
 
The following screenshot displays the GridView consisting of TextBoxes whose values are populated using Bind function.
Difference between Eval and Bind functions in ASP.Net
 
Now if you try to replace Bind function with Eval and then click Update button, you will receive the following error. This happens because when you use Eval function with an UpdateCommand, it returns NULL value to the UpdateCommand and hence the Update operation fails.
Difference between Eval and Bind functions in ASP.Net
 
Downloads