|
用模板列,gridview的RowDataBound事件中处理在DataFormatString 中填写 {0:f} 或{0:D} <asp:TemplateField HeaderText="时间"> <EditItemTemplate> <asp:Label ID="Label1" runat="server" Text=' <%# Eval("dtime", "{0:w}") %>'> </asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text=' <%# Bind("dtime", "{0:w}") %>'> </asp:Label> </ItemTemplate> </asp:TemplateField> 显示格式怎么改成星期???先下载这个: http://download.csdn.net/source/303569
然后: using Insus.NET;
InsusDateTimeUtility obj = new InsusDateTimeUtility();
<asp:Label ID="Label1" runat="server" Text=' <%# obj.GetChineseWeekName(Convert.ToDateTime (Eval("dtime")).DayOfWeek) %>'> 在RowDataBound事件中处理 label lb1=e.row.findcontrol("label1"); datetime dt=convert.todatetime(lb1.text) lb1.text=dt.dayofweek;
自己整理一下就OK了格式化 Eval("dtime", "{0:dddd}") |