locked
ASP.NET , Gridview display date and day RRS feed

  • Question

  • User-1683022223 posted

    hello i am looking how to  display date then day in Gridview 

    like 

    Monday

    20-01-2021

    not like  Monday 20-01-2021

    my code HTML

     <asp:Label ID="lbldate2" runat="server" Text='<%# Eval("datestart", "{0:ddd yyyy/MM/dd}") %>'></asp:Label>

    Saturday, January 16, 2021 7:32 PM

Answers

  • User-943250815 posted

    Considering your Label is in a TemplateField place a <br /> in your format string,

    '<%# Eval("datestart","{0:ddd<br />yyyy/MM/dd}") %>'

    On the other hand if you want make same with BoundField, you have to set HtmlEncode = false

    <asp:BoundField DataField="datestart" HeaderText="datestart" SortExpression="datestart" DataFormatString="{0:ddd<br />yyyy/MM/dd}" HtmlEncode="False">




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 16, 2021 7:56 PM

All replies

  • User-943250815 posted

    Considering your Label is in a TemplateField place a <br /> in your format string,

    '<%# Eval("datestart","{0:ddd<br />yyyy/MM/dd}") %>'

    On the other hand if you want make same with BoundField, you have to set HtmlEncode = false

    <asp:BoundField DataField="datestart" HeaderText="datestart" SortExpression="datestart" DataFormatString="{0:ddd<br />yyyy/MM/dd}" HtmlEncode="False">




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 16, 2021 7:56 PM
  • User-1683022223 posted

    thanks for fast replay jzero

    the code html work very well ....

    update : 

     <asp:Label ID="lbldate2" runat="server" Text='<%# Eval("datestart", "{0:ddd <br /> yyyy/MM/dd}") %>'></asp:Label>

    Saturday, January 16, 2021 8:22 PM
  • User-943250815 posted

    I did not understand your issue, please tell us more about your last issue.

    Saturday, January 16, 2021 9:36 PM
  • User-1683022223 posted

    i update  the  post , did not see the code <br/> 

    work very well  . no error 

    Saturday, January 16, 2021 9:45 PM