Text =''的含义是什么? [英] What is the meaning of Text=''.

查看:295
本文介绍了Text =''的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Text =''<%#Eval(XXXXX)%>''
的含义是什么/>
有什么区别

 <   asp:标签    ID   =   xxxxxx    runat   =  server   文字  ='  <%  #Eval(  xxxx)%>' >  





 <   asp:L abel     ID   =  xxxxxx    runat   =  server   文字  ='  xxxxx' >  



??

解决方案

Eval用于绑定到设置的UI项目是只读的(例如:标签或只读文本框),即Eval用于单向绑定 - 用于从数据库读取到UI字段。



它通常用于后期绑定数据(从开始时不知道),并且通常绑定到包含整个记录的数据绑定控件的最小部分。 Eval方法采用数据字段的名称,并返回一个字符串,该字符串包含数据源中当前记录中该字段的值。您可以提供可选的第二个参数来指定返回字符串的格式。字符串格式参数使用为String类的Format方法定义的语法。


Text =''<%#Eval(xxxx)%>'' - 标签显示dataSource'''xxxx''字段值。



Text =''xxxx'' - 标签显示字符串''xxxx''


第二个示例将始终将其文本设置为 xxxxx

第一个示例更复杂:它获取属性的值 xxxxx 。因此,如果属性 xxxxxx 设置为Hello,则标签将使用后期绑定显示Hello。通常,这用作模板的一部分(在这种情况下,属性是当前数据的一部分),但是可以在模板外部使用它来绑定到页面/控件的类上的属性。 Eval 是只读的:值从源绑定到控件。有一个类似的方法 Bind 这是双向的,因此属性的值将使用控件的值进行更新。显然你不会使用带有标签控件的 Bind ,因为值不会改变,双向绑定比单向<$ c $有更大的开销。 ç>评估

What is the meaning of Text=''<%# Eval("XXXXX") %>''.
What is the difference between

<asp:Label ID="xxxxxx" runat="server" Text='<%# Eval("xxxx") %>'> 


and

<asp:Label ID="xxxxxx" runat="server" Text='xxxxx'>


??

解决方案

Eval is used to bind to an UI item that is setup to be read-only (eg: a label or a read-only text box), i.e., Eval is used for one way binding - for reading from a database into a UI field.

It is generally used for late-bound data (not known from start) and usually bound to the smallest part of the data-bound control that contains a whole record. The Eval method takes the name of a data field and returns a string containing the value of that field from the current record in the data source. You can supply an optional second parameter to specify a format for the returned string. The string format parameter uses the syntax defined for the Format method of the String class.


Text=''<%# Eval("xxxx") %>'' - label displays dataSource''s ''xxxx'' field value.

Text=''xxxx'' - Label displays string ''xxxx''


The second example will have always have it''s text set to xxxxx
The first example is more complicated: it gets the value of a property called xxxxx. So if the property xxxxxx is set to "Hello", the label will display Hello, using late binding. Most often this is used as part of a template (in which case the property is part of the current data), but it is possible to use it outside a template to bind to a property on the page/control''s class. Eval is read only: the value is bound from the source to the control. There is a similar method Bind which is two-way, so the value of the property will be updated with the control''s value. Obviously you wouldn''t use Bind with a label control as the value won''t change and two-way binding has a greater overhead than the one way Eval


这篇关于Text =''的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆