我用以下的方法绑定的一个日期时间型数据,
 <%# DataBinder.Eval(Container.DataItem, "u_AddDate", "{0:yyyy-mm-dd}")%> u_AddDate的值为:2009-2-24 10:09:39,我希望绑定后输出的结果:2009-2-24或2009-02-24,但输出的结果却是:2009-2-24 10:09:39
请问是怎么回事?

解决方案 »

  1.   

    <asp:label ID="Time" runat =server Text ='<%#Eval("u_AddDate","{0:yyyy/MM/dd}") %>'></asp:label>
      

  2.   

    麻烦多给我点分,我的分不够了
    <asp:label ID="time" runat =server Text ='<%#Eval("u_AddDate","{0:yyyy/MM/dd}") %>'></asp:label>
    可以,要是不行告诉我
      

  3.   

    这样就可以的呀<%# Eval("Birthday", "{0:yyyy-MM-dd}") %>
      

  4.   

    <%#Eval("u_AddDate","{0:yyyy-MM-dd}") %>
      

  5.   

    如果不行,可以在RowDataBound事件里这样
    e.Row.Cells[2].Text = DateTime.Parse(e.Row.Cells[2].Text).ToString("yyyy-MM-dd");
      

  6.   

    我干脆 <%# DataBinder.Eval(Container.DataItem, "u_AddDate").ToString()==""?"":DataBinder.Eval(Container.DataItem, "u_AddDate").ToString().Substring(0,10)%>
      

  7.   

    DataFormatString="{0:yyyy-MM-dd}"