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

推荐订阅源

WordPress大学
WordPress大学
T
Threatpost
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
月光博客
月光博客
V
Visual Studio Blog
T
Tailwind CSS Blog
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
Jina AI
Jina AI
J
Java Code Geeks
Martin Fowler
Martin Fowler
大猫的无限游戏
大猫的无限游戏
Recorded Future
Recorded Future
C
Check Point Blog
腾讯CDC
N
Netflix TechBlog - Medium
aimingoo的专栏
aimingoo的专栏
罗磊的独立博客
Hacker News: Ask HN
Hacker News: Ask HN
SecWiki News
SecWiki News
博客园 - Franky
Hacker News - Newest:
Hacker News - Newest: "LLM"
N
News | PayPal Newsroom
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security @ Cisco Blogs
W
WeLiveSecurity
The Last Watchdog
The Last Watchdog
Cloudbric
Cloudbric
F
Full Disclosure
The Cloudflare Blog
Y
Y Combinator Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
S
Schneier on Security
Schneier on Security
Schneier on Security
Spread Privacy
Spread Privacy
L
LINUX DO - 热门话题
AI
AI
N
News and Events Feed by Topic
T
Tor Project blog
P
Palo Alto Networks Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
G
Google Developers 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 的时候,还可以在<%# 和 %>写入代码来对内容作出处理,而处理的结果将作为返回值被传出来。