惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - 疾风

Internet Explorer允许的URL最大长度为2083个字符(Maximum URL length is 2,083 characters in Internet Explorer) 古筝和古琴有什么区别? 认识CSS中absolute与relative BAT详细手册 iframe的使用 领域逻辑的实现分类 面向对象问答 用户点击Log In按钮后发生了什么?(续篇1) 用户点击Log In按钮后发生了什么? 微软的在线RSS阅读器 2003年至2006年项目总结 经常会有一些Gmail的邀请函 Visual Studio 2005 RTM的奇怪问题 在.Net代码中验证XML文档 2006年的一些目标 创建强类型的程序集 在.net中使用强类型来读取配置信息 自己做了一个单元测试的小工具---EasyTest.net How to gets the path for the executable file?
Eval和Bind
疾风 · 2006-10-13 · via 博客园 - 疾风

    在Asp.net(2.0?)中,我们可是使用两种方法来绑定数据,一为Eval,一为Bind。下面是使用这两种绑定方法的例子:

 1 <EditItemTemplate>
 2   <table>
 3     <tr>
 4       <td align=right>
 5         <b>Employee ID:</b>
 6       </td>
 7       <td>
 8         <%# Eval("EmployeeID") %>
 9       </td>
10     </tr>
11     <tr>
12       <td align=right>
13         <b>First Name:</b>
14       </td>
15       <td>
16         <asp:TextBox ID="EditFirstNameTextBox" RunAt="Server"
17           Text='<%# Bind("FirstName") %>' />
18       </td>
19     </tr>
20     <tr>
21       <td align=right>
22         <b>Last Name:</b>
23       </td>
24       <td>
25         <asp:TextBox ID="EditLastNameTextBox" RunAt="Server"
26             Text='<%# Bind("LastName") %>'  />
27       </td>
28     </tr>
29     <tr>
30       <td colspan="2">
31         <asp:LinkButton ID="UpdateButton" RunAt="server"
32           Text="Update" CommandName="Update" />
33         &nbsp;
34         <asp:LinkButton ID="CancelUpdateButton" RunAt="server"
35           Text="Cancel" CommandName="Cancel" />
36       </td>
37     </tr>
38   </table>
39 </EditItemTemplate>

    那么,它们之间有什么区别呢?MSDN中说得很清楚啦,呵呵:

    The Eval function is used to define one-way (read-only) binding.
    The Bind function is used for two-way (updatable) binding.The Bind method takes the name of a data field to associate with the bound property.

    也就是说,Eval用于显示只读的数据,而Bind既可以放置只读的数据又可以放置可以更新的数据。此外,Bind方法还把字段和控件的绑定属性联系起来,使得数据控件(比如GridView、FormView和其他数据库控件)的Update、Insert和Delete等方法可以使用这种联系来作出相应的处理。

    另外,在使用Eval和Bind 的时候,还可以在<%# 和 %>写入代码来对内容作出处理,而处理的结果将作为返回值被传出来。