Differences between eval and bind in Asp.net Data Binding

Source: Internet
Author: User
For example: Code
< Edititemtemplate >  
< ASP: Label ID = "Cityidlabel1" Runat = "Server" Text = '<% # Eval ("cityid") % > '> </ ASP: Label >  
< ASP: textbox ID = "Citytextbox" Runat = "Server" Text = '<% # BIND ("city") % > '> </ ASP: textbox >  
</ Edititemtemplate >  

Eval is a common binding syntax in ASP. net1.1. It is "one-way", that is, the corresponding value of the data source is assigned to the control during the binding, and the eval task is completed.
The so-called "two-way" of BIND is: when binding, assign the corresponding value on the data source to the control, and at the time of submission, automatically extract the value entered on the control.

Another example:
Eval: displays read-only data. BIND: You can bind read-only data or update data. The bind method also associates fields with the binding property of the control, this makes it possible to use the update, insert, and delete methods of data controls (such as the gridview) for corresponding processing.

The data bound to eval and bind is displayed in <% # %>. If you modify or operate the data to be displayed, it is also in <% # %>. For example:
1. Character Display of the displayed string:

<% #( Eval ( " Address " ). Tostring (). substring ( 0 , 10 ) %>

The 10-digit address is displayed.
2. Determine the displayed information:

<% #( Eval ( " If_delete " ). Tostring =   " Yes " ? " Deleted " : " Not deleted "   %>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.