DateTimeColumn will not filter correctly

2 posts, 0 answers
  1. Geoff
    Geoff avatar
    27 posts
    Member since:
    May 2012

    Posted 07 Jul 2016 Link to this post

    I have a programmatically created radgrid. One Column in the grid is a GridDateTimeColumn. I have allowed filtering on this column, but I can not get it to filter to the exact date. I initially was trying to do format so I could filter on date and time, but I would settle for just the date at this point if it got it working. The column created code is:


    GridDateTimeColumn bc40 = new GridDateTimeColumn();
    bc40.PickerType = GridDateTimeColumnPickerType.DatePicker;
    bc40.DataField = "LaunchDate";
    bc40.HeaderText = "LaunchDate";
    bc40.UniqueName = "LaunchDate";
    bc40.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
    bc40.AutoPostBackOnFilter = true;
    bc40.DataFormatString = "{0:MM/dd/yyyy}";
    bc40.EnableTimeIndependentFiltering = true;
    bc40.FilterDateFormat = "MM/dd/yyyy";
    bc40.DataType = typeof(System.DateTime);
    bc40.Display = true;


    I have try muliple variations of FormatString, FilterFormats, Disabled TimeIndepence with no such luck. I though it may be looking directly at the grid's format, so I have also added this to my ItemDataBound event:


    DateTime launchDateTime = DateTime.Parse(item["LaunchDate"].Text.ToString());
    string formattedDateTime = String.Format("{0:MM/dd/yyyy}", launchDateTime);
    item["LaunchDate"].Text = formattedDateTime;


    The date on the grid shows up in the format of 01/01/2016. The format in the filter shows up as 01/01/2016. But when the filter of "Equal To" is set, I don't retrieve any records.


    This filter is a requirement for my application to work properly. Any help would be greatly appreciated.


  2. Eyup
    Eyup avatar
    4075 posts

    Posted 12 Jul 2016 Link to this post

    Hi Geoff,

    Please create the grid structure during Page_Init event handler and add the properties before the grdContingentDevelopment.MasterTableView.Columns.Add(TotalColumn) line:

    I hope this will prove helpful.

    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.
Back to Top