All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
asp.net(c#)如何把字符串转换成数组_[Asp.Net教程]
2003环境下如何手工修复安装.NET1.1_服务器技术_编程技术
如何禁止flash动画的自动跳转_JavaScript技术_编程技术
SQL,Server,安装,(SQL,Server,2008,R2)_mssql学习_编程技术
实例:ASP.NET遍历配置文件的连接字符串_.net资料_编程技术
在Visual,C#中定义和使用自己的特性_.net资料_编程技术
测试,Apache,Web,和,PHP,应用程序服务器_php资料_编程技术
delphi浮动工具栏实例
Page_Init、Page_Load,方法的使用原理_[Asp.Net教程]
SQL的排序,分组,统计常用语句_[SQL Server教程]
Reading number is top 10 pictures
This is heaven to some path
The cat shit
恶搞漫画1
水晶头骨造型的酒瓶
Take you to walk into the most true north Korea rural4
自己约的炮,含泪也要打完
代沟,真好
这酸爽,让人不敢相信
Extremely rare TianShan Mountains snow lotus2
鸡也看毛片
Download software ranking
金山office2007
Sora aoi - one of more PK
传奇私服架设教程
Boxer's Top ten classic battle3
Sora aoi‘s film--Lust fan wall
Boxer Classic video2
Unix video tutorial13
Ashlynn Video2
Boxer's Top ten classic battle8
Tram sex maniac 2 (H) rar bag15
归海一刀 published in(发表于) 2014/1/30 1:26:33 Edit(编辑)
DataBinder.Eval使用方法总结_[Asp.Net教程]

DataBinder.Eval使用方法总结_[Asp.Net教程]

DataBinder.Eval使用方法总结_[Asp.Net教程]
<%# Bind("Subject") %> //绑定字段
<%# Container.DataItemIndex + 1%> //实现自动编号
<%# DataBinder.Eval(Container.DataItem, "[n]") %>

通常使用的方法
<%# DataBinder.Eval(Container.DataItem, "ColumnName") %>
<%# DataBinder.Eval(Container.DataItem, "ColumnName", null) %>
<%# DataBinder.Eval(Container, "DataItem.ColumnName", null) %>

其他用法
<%# ((DataRowView)Container.DataItem)["ColumnName"] %>
<%# ((DataRowView)Container.DataItem).Row["ColumnName"] %>
<%# ((DataRowView)Container.DataItem)["adtitle"] %>
<%# ((DataRowView)Container.DataItem)[n] %>
<%# ((DbDataRecord)Container.DataItem)[0] %>
<%# (((自定义类型)Container.DataItem)).属性.ToString() %>//如果属性为字符串类型就不用ToString()了

DataBinder.Eval用法范例
<%# DataBinder.Eval(Container.DataItem, "IntegerValue", "{0:c}") %>
格式化字符串参数是可选的。如果忽略参数,DataBinder.Eval 返回对象类型的值,

//显示二位小数
<%# DataBinder.Eval(Container.DataItem, "UnitPrice", "${0:F2}") %>
//{0:G}代表显示True或False
<ItemTemplate>
<asp:Image Width="12" Height="12" Border="0" runat="server"
AlternateText
='<%# DataBinder.Eval(Container.DataItem, "Discontinued", "{0:G}") %>'
ImageUrl='
<%# DataBinder.Eval(Container.DataItem, "Discontinued", "~/images/{0:G}.gif") %>' />
ItemTemplate>
//转换类型
((string)DataBinder.Eval(Container, "DataItem.P_SHIP_TIME_SBM8")).Substring(4,4)
{0:d} 日期只显示年月日
{0:yyyy-mm-dd} 按格式显示年月日
{0:c} 货币样式
<%#Container.DataItem("price","{0:¥#,##0.00}")%>
<%# DataBinder.Eval(Container.DataItem,"Company_Ureg_Date","{0:yyyy-M-d}")%>

Specifier Type Format Output (Passed Double 1.42) Output (Passed Int -12400)
c Currency {0:c} $1.42 -$12,400
d Decimal {0:d} System.FormatException -12400
e Scientific {0:e} 1.420000e+000 -1.240000e+004
f Fixed point {0:f} 1.42 -12400.00
g General {0:g} 1.42 -12400
n Number with commas for thousands {0:n} 1.42 -12,400
r Round trippable {0:r} 1.42 System.FormatException
x Hexadecimal {0:x4} System.FormatException cf90

{0:d} 日期只显示年月日
{0:yyyy-mm-dd} 按格式显示年月日

样式取决于 Web.config 中的设置

{0:c} 或 {0:£0,000.00} 货币样式 标准英国货币样式
<system.web>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" uiCulture="en-US" />
system.web>
显示为 £3,000.10

{0:c} 或 string.Format("{0:C}", price); 中国货币样式
<system.web>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="zh-cn" uiCulture="zh-cn" />
system.web>
显示为 ¥3,000.10

{0:c} 或 string.Format("{0:C}", price); 美国货币样式
<system.web>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
system.web>
显示为 $3,000.10

DataBinder.Eval(Container.DataItem,"Name")和Container.DataItem("Name")有什么区别?
DataBinder是System.Web里面的一个静态类,它提供了Eval方法用于简化数据绑定表达式的编写,但是它使用的方式是通过Reflection等开销比较大的方法来达到易用性,因此其性能并不是最好的。而Container则根本不是任何一个静态的对象或方法,它是ASP.NET页面编译器在数据绑定事件处理程序内部声明的局部变量,其类型是可以进行数据绑定的控件的数据容器类型(如在Repeater内部的数据绑定容器叫RepeaterItem),在这些容器类中基本都有DataItem属性,因此你可以写Container.DataItem,这个属性返回的是你正在被绑定的数据源中的那个数据项。如果你的数据源是DataTable,则这个数据项的类型实际是DataRowView。



添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.