All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
GridView列显示时间货币格式字符串_[Asp.Net教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/1/30 1:28:02 Browse times: 315 Comment times: 0

GridView列显示时间货币格式字符串_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

GridView列显示时间货币格式字符串_[Asp.Net教程] 效果图:
图1-未格式化前

图2-格式化后

解决方法:
在asp.net 2.0中,如果要在绑定列中显示比如日期格式等,如果用下面的方法是显示不了的
DataFormatString="{0:M-dd-yyyy}"
HeaderText="CreationDate" />
主要是由于htmlencode属性默认设置为true,已防止XSS攻击,安全起见而用的,所以,可以有以下两种方法解决
1、


DataFormatString="{0:M-dd-yyyy}"
HtmlEncode="false"
HeaderText="CreationDate" />


将htmlencode设置为false即可
另外的解决方法为,使用模版列




Text=’<%# Eval("CreationDate", "{0:M-dd-yyyy}") %>’>



Text=’<%# Bind("CreationDate", "{0:M-dd-yyyy}") %>’>








There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.