I have a Telerik Grid with one of the column having Date Time values, but the filter on that field is not working as the filter only accepts date by default. Is there any way we
protected void ItemsRadGrid_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.FilterCommandName)
{
try
{
FillItemsGrid();
FilterByDate(ItemsRadGrid, e);
}
catch (Exception ex)
{
//ExceptionLogClass.InsertError(ex);
}
}
}
public static void FilterByDate(RadGrid grid, GridCommandEventArgs e)
{
Pair filterPair = e.CommandArgument as Pair;
string columnName = Convert.ToString(filterPair.Second);
if (filterPair.First.ToString() == "NoFilter")
{ }
else
{
if (grid.Columns.FindByDataField(columnName).DataType.Name == "DateTime")
{
try
{
TextBox FilterColumnField = ((TextBox)((GridFilteringItem)e.Item)[columnName].Controls[0]);
string oldDate = FilterColumnField.Text;
FilterColumnField.Text = DateTime.ParseExact(FilterColumnField.Text, "dd.MM.yyyy", CultureInfo.InvariantCulture).ToString("MM/dd/yyyy 12:00:00 tt");
}
catch (FormatException)
{
e.Canceled = true;
}
}
}
}