DataFormatString doesn't seem to work

2 posts, 0 answers
  1. StuartLittle
    StuartLittle avatar
    20 posts
    Member since:
    Apr 2018

    Posted 22 Jun 2018 Link to this post

    I am using the latest Telerik.

    My RadGrid has a date column and I am trying to format it but it doesn't work.

    <telerik:RadGrid RenderMode="Lightweight" runat="server" ID="RadGrid1" AllowPaging="True" AllowSorting="true" OnInit="RadGrid1_Init" 
                                    PageSize="15"   AllowFilteringByColumn="true"   OnNeedDataSource="RadGrid1_NeedDataSource" OnPreRender="RadGrid1_PreRender" Font-Size="Small">
                    
                    <MasterTableView>
                        <Columns>
                            <telerik:GridDateTimeColumn DataField="BillDate" UniqueName="BillDateColumn1" DataFormatString="{0:dd/MM/yyyy}"  HeaderText="Bill Date1" />
                            <telerik:GridBoundColumn DataType="System.DateTime" DataField="BillDate" UniqueName="BillDateColumn2" DataFormatString="{0:dd/MM/yyyy}"  HeaderText="Bill Date2" /> 
                        </Columns>
                    </MasterTableView>
                </telerik:RadGrid>

     

    In both columns, I get format like 4/30/2017 12:00:00 AM instead of just 4/30/2017.

    Is there anything I am missing here?

  2. StuartLittle
    StuartLittle avatar
    20 posts
    Member since:
    Apr 2018

    Posted 22 Jun 2018 in reply to StuartLittle Link to this post

    Please delete the question.

    By mistake, I had set the datatype of date as string in the class definition.

Back to Top