<%# 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

.NET中Eval()方法大全的更多相关文章

  1. js中eval() 方法的使用以及一些特殊的使用方式

    1.eval方法只能在非严格模式中进行使用,在use strict中是不允许使用这个方法的. 2.eval函数接收一个参数s,如果s不是字符串,则直接返回s.否则执行s语句.如果s语句执行结果是一个值 ...

  2. javaScript中eval()方法转换json对象

    <script language="javascript"> var user = '{name:"张三",age:23,'+ 'address:{ ...

  3. js中数组方法大全

    js数组方法大全 一:前言 我们在学到js中数组的时候,我们会接触到js中数组的一些方法,这些方法对我们来说,可以很遍历的达到我们想要的结果,但是因为方法比较多,有些方法也不常用,可能会过一段时间就会 ...

  4. ASP.NET中EVAL用法大全

    <%# Bind("Subject") %> //绑定字段<%# Container.DataItemIndex + 1%> //实现自动编号<%# ...

  5. Java中时间方法大全01(持续更新)

    下面这些方法都可以封装到一个工具类中 /** * 获取当前时间的时间戳 */ public static int getCurrentTimeIntValue() { return (int) (Sy ...

  6. python中eval方法的使用

    eval函数就是实现list.dict.tuple与str之间的转化str函数把list,dict,tuple转为为字符串# 字符串转换成列表a = "[[1,2], [3,4], [5,6 ...

  7. 使用jquery中height()方法获取各种高度大全

    alert($(window).height()); //浏览器当前窗口可视区域高度 alert($(document).height()); //浏览器当前窗口文档的高度 alert($(docum ...

  8. ASP.NET中的Eval与DataBinder.Eval()方法

    1.bind是一种双向数据绑定,有数据源时才会有改变. 2..net1.x版本中有DataBinder(Container.DataItem,"数据项")  单向数据绑定 .net ...

  9. 用Java开发一个工具类,提供似于js中eval函数功能的eval方法

    今天在看到<Java疯狂讲义>中一个章节习题: 开发一个工具类,该工具类提供一个eval()方法,实现JavaScript中eval()函数的功能--可以动态运行一行或多行程序代码.例如: ...

随机推荐

  1. Linux安装httpd2.4.10

    1. cd /mnt tar zxvf httpd-2.4.10.tar.gz ./configure --prefix=/mnt/apache2 --enable-dav --enable-modu ...

  2. 【Python】随机漫步

    创建Randomwalk()类 我们将使用Python来生成随机漫步数据,再使用matplotlib以引入瞩目的方式将这些数据呈现出来 首先创建类Randomwalk() from random im ...

  3. asp.net模拟请求

    在asp.net模拟请求,微软在控件状态有安全性控制. __VIEWSTATE.__EVENTVALIDATION要与服务端页面(.aspx)中元素信息保存一致.

  4. typedef 与 define 的区别

    1.区别 (1)定义.执行时间.作用域 定义.执行时间: #define pchar char * typedef char *pchar; 定义的格式差别,显而易见的,要注意,define 是不能存 ...

  5. springMVC --@RequestParam注解(后台控制器获取參数)

    在SpringMVC后台控制层获取參数的方式主要有两种,一种是request.getParameter("name"),第二种是用注解@RequestParam直接获取. 1.获取 ...

  6. HTML5开发移动web应用——SAP UI5篇(8)

    本次对之前学习的SAP UI5框架知识进行简单小结.以及重点部分知识的梳理. 1.在UI5使用过程中,命名空间的概念非常重要. 2.一般的sap组件引用格式例如以下: sap.ui.define([ ...

  7. 如何利用JQuery获取iframe内联框架对象?

    parent.$("#iframeID").get(0).contentWindow; 父.$("选择器").get(0).contentWindow; get ...

  8. Svn服务器备份迁移小结

    注:svn备份千万不要采用打包压缩,然后解压文件的方式. 备份和还原之前先要关掉svn服务器. svn备份一般采用三种方式: 1)svnadmin dump 2)svnadmin hotcopy 3) ...

  9. /usr/bin/mysqld_safe_helper: Cannot change uid/gid (errno: 1) (转)

    From: https://www.rootusers.com/how-to-fix-mariadb-10-0-29-selinux-update-failure/ 安装mysql 10.0.29后, ...

  10. EasyPlayerPro Windows播放器电子放大/局部放大播放功能实现

    背景描述 在视频监控软件中,我们看到很多的软件都有电子放大功能, 按住鼠标左键不放,框选一个区域,再松开鼠标左键,即对选中的区域进行放大显示, 且可以重复该操作,逐步放大所需显示的区域, 有没有觉得, ...