GridView中如何實(shí)現(xiàn)自定義時(shí)間貨幣等字符串格式?方法一: <asp :GridView ID="GridView1" runat="server"> <columns> <asp :BoundField DataField="CreationDate" DataFormatString="{0:M-dd-yyyy}" HtmlEncode="false" HeaderText="CreationDate" /> </columns> </asp> 將htmlencode設(shè)置為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> {0:D4}由0填充的4個(gè)字符寬的字段中顯示整數(shù); {0:000.0}四舍五入小數(shù)點(diǎn)保留第幾位有效數(shù)字; {0:N2}小數(shù)點(diǎn)保留2位有效數(shù)字;{0:N2}% 小數(shù)點(diǎn)保留2位有效數(shù)字加百分號(hào); {0:D}長(zhǎng)日期;{0:d}短日期;{0:yy-MM-dd} 例如07-3-25;;{0:yyyy-MM-dd} 例如2007-3-25 |
|
來(lái)自: 悟靜 > 《.net和asp.net》