This is a migrated thread and some comments may be shown as answers.

The date format does not work

1 Answer 173 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Patrik
Top achievements
Rank 2
Patrik asked on 22 Sep 2016, 04:24 PM

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?

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 27 Sep 2016, 10:31 AM
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.
Tags
ListView
Asked by
Patrik
Top achievements
Rank 2
Answers by
Viktor Tachev
Telerik team
Share this question
or