Change Autogenerated column from DateTime to short date

2 posts, 0 answers
  1. Jeff
    Jeff avatar
    6 posts
    Member since:
    May 2016

    Posted 30 Jun 2016 Link to this post

    I am using a stored procedure to get a DateTable of ID (int) start date and end date (both Date Time).  The columns are autogenerated.  I want both date time fields to have just the date.  I saw in the ItemDataBound to select the columns that have DateTime, but I do not see how to change the values to just date.  I am using C#

    (if (col,DateType == typeof(DateTime))





  2. Viktor Tachev
    Viktor Tachev avatar
    2499 posts

    Posted 05 Jul 2016 Link to this post

    Hi Jeff,

    You can customize the format of the date in the ColumnCreated event for the grid. The event is raised for every column. You can check if the currently created column is a GridDateTimeColumn and set the DataFormatString property for it.

    protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
        if (e.Column is GridDateTimeColumn)
            (e.Column as GridDateTimeColumn).DataFormatString = "{0:dd/MM/yyyy}";

    For additional information on using AutoGenerated columns in the grid you would find the following article interesting.

    Viktor Tachev
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top