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

推荐订阅源

The Hacker News
The Hacker News
博客园_首页
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
Blog — PlanetScale
Blog — PlanetScale
博客园 - 三生石上(FineUI控件)
A
About on SuperTechFans
V
Visual Studio Blog
小众软件
小众软件
MyScale Blog
MyScale Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Full Disclosure
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Exploit Database - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
T
Threat Research - Cisco Blogs
AWS News Blog
AWS News Blog
T
Tor Project blog
Jina AI
Jina AI
GbyAI
GbyAI
C
Comments on: Blog
IT之家
IT之家
Apple Machine Learning Research
Apple Machine Learning Research
A
Arctic Wolf
有赞技术团队
有赞技术团队
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
Security Latest
Security Latest
Webroot Blog
Webroot Blog
C
Cisco Blogs
雷峰网
雷峰网
云风的 BLOG
云风的 BLOG
博客园 - 叶小钗
K
Kaspersky official blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
宝玉的分享
宝玉的分享
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
H
Hacker News: Front Page
D
Darknet – Hacking Tools, Hacker News & Cyber Security
D
Docker
P
Palo Alto Networks Blog
The Register - Security
The Register - Security
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
阮一峰的网络日志
阮一峰的网络日志

博客园 - Titans

一个想嫁有钱人的女孩得到的回复 ASP.NET 中执行 URL 重写 - Titans 在 ASP.NET 中执行 URL 重写 国外C#开源系统一览表 五蕴皆空 项目管理一些体会 职场好人缘的26个细节 试译Fowler的《更多企业应用架构模式》稿 C# String Library ASP.NET 2.0页面框架的几处变化 ADO.NET 2.0 大批量数据操作和多个动态的结果集 ASP.NET 2.0 中收集的小功能点 战将宣言 Titans:小天使 日历控件源码开放--适用于ASP.NET 1.1 爱的距离 华为的冬天 - Titans - 博客园 每件事都有它的道理 搜索引擎优化排名方法
小tips:asp.net 2.0中在gridview中使用DataFromatString
Titans · 2006-09-25 · via 博客园 - Titans

可能之前不少朋友也已经试过,但我是今天才遇到这个问题,翻查资料后才解决。主要是
在asp.net 2.0中,如果要在绑定列中显示比如日期格式等,如果用下面的方法是显示不了的

<asp :BoundField DataField=“CreationDate”  
     DataFormatString
={0:M-dd-yyyy}”  
     HeaderText
=“CreationDate”   />

主要是由于htmlencode属性默认设置为true,已防止XSS攻击,安全起见而用的,所以,可以有以下两种方法解决
1、

<asp :GridView ID=“GridView1″ runat=“server”>
<columns>
  
<asp :BoundField DataField=“CreationDate”  
     DataFormatString
={0:M-dd-yyyy}”  
     HtmlEncode
=false
     HeaderText
=“CreationDate”    />
</columns>
</asp>

将htmlencode设置为false即可

另外的解决方法为,使用模版列

<asp :GridView ID=“GridView3″ runat=“server”  >
 
<columns>
  
<asp :TemplateField HeaderText=“CreationDate” >
   
<edititemtemplate>
    
<asp :Label ID=“Label1″ runat=“server” 
      Text
=<%# Eval("CreationDate""{0:M-dd-yyyy}"%>>
    
</asp>
   
</edititemtemplate>
   
<itemtemplate>
    
<asp :Label ID="Label1" runat="server" 
      Text
=<%# Bind(“CreationDate”, “{0:M-dd-yyyy}”) %>>
    
</asp>
   
</itemtemplate>
  
</asp>
 
</columns>
</asp> 

转载自:http://www.cnblogs.com/jackyrong/archive/2006/08/28/488282.html