I have a problem with Date Filter.
This is my Radgrid
When I filter wiht 15/02/2012 --> does not return nothing.
I need SHOW DATE + HOUR, is important!
.. I try this
protected void ActivityLog_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.FilterCommandName)
{
Pair filterPair = e.CommandArgument as Pair;
string columnName = Convert.ToString(filterPair.Second);
if (columnName == "Date")
{
e.Canceled = true;
string date =
((RadDatePicker)((GridFilteringItem)e.Item)[Convert.ToString(filterPair.Second)].Controls[0])
.SelectedDate.ToString();
DateTime startDate = Convert.ToDateTime(date).AddDays(-1);
DateTime endDate = startDate.AddDays(2);
string newFilter = "('" + startDate.ToString("MM/dd/yyyy") + "' < [Date] AND [Date] < '" + endDate.ToString("MM/dd/yyyy") + "')";
GridBoundColumn dateColumn = (GridBoundColumn)e.Item.OwnerTableView.GetColumnSafe(columnName);
dateColumn.CurrentFilterValue = Convert.ToDateTime(date).ToString("MM/dd/yyyy");
ActivityLogGrid.MasterTableView.FilterExpression = newFilter;
ActivityLogGrid.Rebind();
}
}
}
But ReBind does not work.
I use:
- AutogenerateColumns = true
and NeedSource events.
regards