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();
dg.MasterTableView.Columns.Add(bc40);
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.