The date format does not work

2 posts, 0 answers
  1. Patrik
    Patrik avatar
    6 posts
    Member since:
    May 2009

    Posted 22 Sep Link to this post

    Hi,
    I want to format the date in a "dd.MM.yyyy" I've already tried several options but none that work.

    The date is stored in the table as Datetime2.

     

    <telerik:RadListView runat="server" ID="rlvEmployes" ClientDataSourceID="rcdsEmployes">
                <LayoutTemplate>
                    <div class="RadListView RadListView_Default">
                        <ul class="employes-list" id="itemPlaceholder" runat="server" style="list-style-type:none;">
     
                        </ul>
                    </div>
                </LayoutTemplate>
                <ClientSettings>
                    <DataBinding>
                        <ItemTemplate>
                            <li>
                                <div class="itemTemplate" data-employe-id="#= ZamestnanecID #">
                                    <div class="header">#= Prijmeni # #= Jmeno #</div>
                                    <div class="content">
                                        <table>
                                            <tr>
                                                <td>
                                                    <span class="label">Aktivní:</span>
                                                </td>
                                                <td>
                                                    <input type="checkbox" #= Aktivny ? 'checked="checked"' : '' # />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <span class="label">Datum narození:</span>
                                                </td>
                                                <td>
                                                    <span class="info">#= format(DatumNarozeni, "{0:dd/MM/yyyy}") #</span>
                                                </td>
                                                <td>
                                                    <span class="label">Číslo OP:</span>
                                                </td>
                                                <td>
                                                    <span class="info">#= CisloOP #</span>
                                                </td>
     
                                            </tr>
                                        </table>
                                    </div>
                                </div>
                                <div class="editTemplate" style="display:none;">
                                    <telerik:RadTextBox runat="server" Text='#= ZamestnanecID #'></telerik:RadTextBox>
                                </div>
                            </li>
                        </ItemTemplate>
                    </DataBinding>
                </ClientSettings>
            </telerik:RadListView>

     

    Where I make mistakes?

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 27 Sep Link to this post

    Hi Patrik,

    If the date field is a DateTime object it is expected to be stored in the data source as such. Note that the specified format is used only for displaying the date in a format that is easier for the user to read it.

    This approach provides great flexibility when working with dates. Especially when implementing manual logic or calculations. Moreover, when the date is stored as DateTime in the data source there is no need to parse the value entered by the user to determine what is the entered date.

    Regards,
    Viktor Tachev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top