GridView日期格式模版列使用方法
来源:互联网 发布:运用思维导图学编程 编辑:程序博客网 时间:2024/04/30 21:00
在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>
<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>
- GridView日期格式模版列使用方法
- GridView日期格式模版列使用方法
- GridView日期格式模版列使用方法
- gridview列 数字、货币和日期 显示格式
- gridview列 数字、货币和日期 显示格式
- gridview列 数字、货币和日期 显示格式
- GridView绑定列数字、货币和日期的显示格式
- gridview列 数字、货币和日期 显示格式
- gridview列 数字、货币和日期 显示格式
- gridview列 数字、货币和日期 显示格式
- 隐藏gridview第一列 和 设置日期格式
- GridView列数字、货币和日期的显示格式
- gridview列 数字、货币和日期 显示格式
- GridView列数字、货币和日期的显示格式
- C#, GridView列数字、货币和日期的显示格式
- gridview列 数字、货币和日期 显示格式
- GridView列数字、货币和日期的显示格式
- GridView列数字、货币和日期的显示格式
- The Most Important Design Guideline?
- Hibernate分页查询原理解读
- Spring+Hibernate+Struts技术的一个分页程序
- JavaScript实现的分页(样式2)
- 惊叹!---就算大自然的鬼斧神功也造就不出如此的代码
- GridView日期格式模版列使用方法
- JDBC (二)
- 内核级Rootkit技术入门(1)
- 【原创翻译】COM入门简介 -- 什么是COM , 怎样使用它 (3)
- X Window研究笔记(16)
- cisco2960密码破解
- 【原创】蚂蚁爬杆问题之java实现
- 【盟军敢死队:二战英雄修改器实现】【感慨一下古龙群侠传这个修改器的编写过程】
- 给asp控件添加js方法