将SQL Server数据库mytable表的time(datetime 类型)绑定到DataGird的label,总是显示小时,分种(例如:2005.8.09 00:00:00)如何只显示日期不显示小时和分种(例如:2005.08.09)!!!

解决方案 »

  1.   

    在sql语句里这样写吧:
    select convert(char(10),日期,120) as 日期 from ...
      

  2.   

    在sql语句里这样写吧:
    select convert(char(10),日期,120) as 日期 from ...
      

  3.   

    在DataGrid1的属性生成器对应列的数据设置表达式为:{0:yyyy-MM-dd hh:mm}
      

  4.   

    错了,应该是:{0:yyyy-MM-dd hh:mm}
      

  5.   

    {0:yyyy-MM-dd}   2005-05-26
    {0:yy-MM-dd}     05-05-26
    {0:dd-MM-yyyy}   26-05-2005
    {0:dd-MM-yyyy}   26-05-05
      

  6.   

    {0:yyyy-MM-dd}   2005-05-26
    {0:yy-MM-dd}     05-05-26
    {0:dd-MM-yyyy}   26-05-2005
    {0:dd-MM-yy}   26-05-05
    上面的沒有看清楚,不好意思
      

  7.   

    label.Text=DateTime.Parse(dr["时间字段"].ToString()).ToShortDateString();
      

  8.   

    <asp:Label id=Label4 Runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "birthday") %>'> 在这里如何添加代码控制显示时间?