Eval是asp.net1.1中常
用的綁定文法,它是“單向”的,即綁定時把資料來源上相應的值賦到該控制項上,Eval的任務就完成了
而Bind所謂的“雙向”就是:在綁定時,把
資料來源上相應的值賦到該控制項上,並且,在提交時,自動提取使用者在該控制項上輸入的值。
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
>
又例:
Eval:綁定的是唯讀資料的顯
示;Bind:可以綁定唯讀資料也可以綁定更新資料,Bind方法還把欄位和控制項的綁定屬性聯絡起來,使得資料控制項(比如GridView等)的
Update、Insert和Delete等方法可以使用這種聯絡來作出相應的處理。
Eval 和 Bind繫結資料在<%#
%> 顯示, 若對要顯示的資料作修改或者操作也在<%# %> 中,例如:
1, 對顯示的字串作字元顯示:
<%
# (
Eval
(
"
Address
"
)).ToString().SubString(
0
,
10
)
%>
顯
示10位元的地址。
2, 對顯示的資訊作判斷:
<%
# (
Eval
(
"
if_delete
"
)).ToString
==
"
yes
"
?
"
已刪
除
"
:
"
未刪除
"
%>--------------------------------------------------------------------------------------------------------------------------------<% %> An embedded code block is server code that executes during
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