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

Datetime records are not showing proper data in RadGrid column from SQL database

2 Answers 57 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Priyanka
Top achievements
Rank 1
Priyanka asked on 03 Jun 2015, 03:32 AM

I am using Telerik RadGrid in my project.

I have a "Datetime" column (CreatedDate) in RadGrid, in which records are shown from SQL Database using DataSource.

 

<asp:ObjectDataSource ID="odsDocumentHistoryAdmin" runat="server" SelectMethod="Query" TypeName="atQuest.Projects.ABC.IPRRequest" SortParameterName="orderBy">
    <SelectParameters>
        <asp:ControlParameter ControlID="ddlStatus" Name="status" PropertyName="SelectedValue"
            Type="Int32" ConvertEmptyStringToNull="true"  />
        <asp:ControlParameter ControlID="txtSearch" Name="searchValue" PropertyName="Text"
            Type="String" ConvertEmptyStringToNull="true" />
    </SelectParameters>
</asp:ObjectDataSource>
 
<telerik:RadGrid ID="qgDocumentHistoryAdmin" runat="server" DataSourceID="odsDocumentHistoryAdmin"
            AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" ShowGroupPanel="True"
            CellSpacing="0" GridLines="None" Width="100%" Skin="Outlook">
            <ClientSettings AllowDragToGroup="True" />
            <GroupingSettings CaseSensitive="false"></GroupingSettings>
            <MasterTableView AllowFilteringByColumn="true" AllowMultiColumnSorting="false" AutoGenerateColumns="false"
                CommandItemDisplay="Top" DataKeyNames="RequisitionNo" EnableGroupsExpandAll="true"
                GroupLoadMode="Client" PageSize="50">
                <CommandItemSettings ShowAddNewRecordButton="false" ShowExportToExcelButton="true" />
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="RequisitionNo" SortOrder="Descending" />
                </SortExpressions>
                <PagerStyle AlwaysVisible="True" PageSizeControlType="RadComboBox" Position="Bottom" PageSizes="50,100,150,200" />
                <Columns>
 
                    <telerik:GridBoundColumn DataField="CreatedDate" HeaderText="Submit Date" SortExpression="CreatedDate"
                        UniqueName="CreatedDate" FilterDelay="2000" ShowFilterIcon="false" DataFormatString="{0: dd/MM/yyyy hh:mm:ss tt}">
                    </telerik:GridBoundColumn>
 
                </Columns>
            </MasterTableView>
            <ExportSettings SuppressColumnDataFormatStrings="True" IgnorePaging="True" ExportOnlyData="True" Excel-Format="ExcelML" OpenInNewWindow="True" FileName="eAPDocHistory" Excel-FileExtension="xls">
            </ExportSettings>
        </telerik:RadGrid>

Few records in Database "DateTime" column have NULL value and few records have proper date and time.

When I run my Web Page, everytime I get "01/01/0001 12:00:00 AM" datetime format in RadGrid "DateTime" column, for all the records.

Despite of proper records in Database, output is not as per expectation.

 

I am new to ASP.NET as well as Telerik Controls. Please reply what I am missing in my code.

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Accepted
Kostadin
Telerik team
answered on 05 Jun 2015, 12:00 PM
Hi Priyanka,

I am afraid I was unable to replicate the issue locally. I prepared a small runnable sample based on the provide code but on my side the proper format is applied to the DateTime object. Could you please give it a try and let me know how it differs from your real setup?

Regards,
Kostadin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Priyanka
Top achievements
Rank 1
answered on 08 Jun 2015, 09:47 AM

Hi Kostadin, 

Thank you for the reply.

I resolved the error. It was because of one missing C# file.

Thanks for the help.

Tags
General Discussions
Asked by
Priyanka
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Priyanka
Top achievements
Rank 1
Share this question
or