how to apply particular FORMAT of date by using eval?

前端 未结 6 758
孤街浪徒
孤街浪徒 2021-01-03 20:45

I have used following code :

 \'> 


        
相关标签:
6条回答
  • 2021-01-03 21:01

    You should be able to use something like this:

    <asp:HyperLink ID="lnkCreatedDate" runat="server" Text='<%#Eval("CREATED_ON", "{0:dd/M/yyyy}")%>'> </asp:HyperLink>
    
    0 讨论(0)
  • 2021-01-03 21:02
    1. I Was Face Problem When Date Is NULL.
    2. It Will Help Me When CREATED_ON Date Is Null.
    3. Use This Code When You Are Not Sure That Your Date Is NULL OR NOT.

      <asp:HyperLink ID="lnkCreatedDate1" runat="server" Text='<%# (String.IsNullOrEmpty(Eval("CREATED_ON").ToString())) ? "" : DateTime.Parse(Eval("CREATED_ON").ToString()).ToString("d") %>'></asp:HyperLink>
      
    0 讨论(0)
  • 2021-01-03 21:10

    this should do the trick:

    <asp:HyperLink ID="lnkCreatedDate" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CREATED_ON", "{0:dd/MM/yyyy}") %>'></asp:HyperLink>
    
    0 讨论(0)
  • 2021-01-03 21:11

    You Can try THis Also

    <asp:HyperLink ID="lnkCreatedDate" runat="server" Text='<%#Eval("CREATED_ON", "{0:d}")%>'> </asp:HyperLink>
    
    0 讨论(0)
  • 2021-01-03 21:16

    You can try this -

    <asp:HyperLink ID="lnkCreatedDate1" runat="server" Text='<%# DateTime.Parse(Eval("CREATED_ON").ToString()).ToString("d") %>'> </asp:HyperLink>   
    
    0 讨论(0)
  • 2021-01-03 21:24

    I suppose you have a DateTime variable named MyDate:

    DateTime MyDate;
    

    If you want juste the date part:

    MyDate.Value.ToString("d");
    

    With the day:

    MyDate.Value.ToString("D");
    

    Here is a usefull doc PDF Doc

    0 讨论(0)
提交回复
热议问题