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

3 posts, 1 answers
  1. Priyanka
    Priyanka avatar
    34 posts
    Member since:
    Dec 2014

    Posted 02 Jun 2015 Link to this post

    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. Answer
    Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 05 Jun 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Priyanka
    Priyanka avatar
    34 posts
    Member since:
    Dec 2014

    Posted 08 Jun 2015 in reply to Kostadin Link to this post

    Hi Kostadin, 

    Thank you for the reply.

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

    Thanks for the help.

Back to Top