Differences between eval and bind in Asp.net Data Binding

Source: Internet
Author: User

Eval is common in ASP. net1.1
The binding syntax is used. It is "one-way", that is, when the data source is bound, the corresponding value is assigned to the control, and the eval task is completed.
The so-called "two-way" of BIND is: when binding
The corresponding values of the data source are assigned to the control. when the control is submitted, the user's input values are automatically extracted.

Document. getelementbyid ('Code _ closed_text_145659 '). style. Display = 'none ';

Document. getelementbyid ('Code _ open_image_145659 '). style. Display = 'inline ';

Document. getelementbyid ('Code _ open_text_145659 '). style. display = 'inline'; "src =" http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif "alt =" "width =" 11 "Height =" 16 "align =" TOP "> document. getelementbyid ('Code _ open_text_145659 '). style. display = 'none ';
Getelementbyid ('Code _ closed_image_145659 '). style. Display = 'inline ';
Getelementbyid ('Code _ closed_text_145659 '). style. display = 'inline'; "src =" http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif "alt =" "width =" 11 "Height =" 16 "align =" TOP "> 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
>
 

Another example:
Eval: bound to the display of read-only data
BIND: You can bind read-only data or update data. The bind method also associates fields with the property bound to the control to enable
Update, insert, delete, and other methods can be used for corresponding processing.

The data bound to eval and bind is in the <% #
%> Display. If you want to 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
)
%>

Display
10-digit address.
2. Determine the displayed information:

<%
#(
Eval
(
"
If_delete
"
). Tostring
=
 
"
Yes
"
?
"
Deleted
Division
"
:
"
Not deleted
"
 
%> Embedded-<%> an embedded code block is server code that executes
The page's render phase. The code in the block can execute Programming
Statements and call functions in the current page class.
Http://msdn2.microsoft.com/en-gb/library/ms178135 (vs.80). aspx

<% =
%> Most useful for displaying single pieces of information.
Http://msdn2.microsoft.com/en-us/library/6dwsdcf5 (vs.71). aspx

<% #
%> Data binding expression syntax.
Http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx

<% $
%> ASP. NET expression.
Http://msdn2.microsoft.com/en-us/library/d5bd1tad.aspx

<% @
%> Directive syntax.
Http://msdn2.microsoft.com/en-us/library/xz702w3e (vs.80). aspx

<% --
-- %> Server-side comments.
Http://msdn2.microsoft.com/en-US/library/4acf8afk.aspx

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.