newstar0101

导航

gridview 日期转成星期显示

gridview 日期转成星期显示
文章来源:转载 点击数: 143 更新时间:2008-5-8 7:28:50 

用模板列,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}") 

posted on 2010-05-21 15:38  newstar0101  阅读(229)  评论(0编辑  收藏  举报