This is a migrated thread and some comments may be shown as answers.

Filter using date in radgrid

1 Answer 135 Views
This is a migrated thread and some comments may be shown as answers.
Debashis Pyne
Top achievements
Rank 1
Debashis Pyne asked on 12 Oct 2010, 11:31 AM
I have separate date and time field in 2 fields at database table. I am bounding it under ItemTemplate of a GridTemplateColumn . It is showing fine but can not be filtered by any means.

<telerik:RadGrid ID="grdDiscussionList" Skin="WebBlue"
runat="server" GridLines="None"
AllowFilteringByColumn = "true"
AllowPaging="True" PageSize="10"

<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
<MasterTableView DataKeyNames="Discussion_Id" CommandItemDisplay="Top" EditMode="PopUp">
<CommandItemSettings ShowAddNewRecordButton="false"/>
<EditFormSettings PopUpSettings-Modal="true" />

<telerik:GridBoundColumn DataField="Discussion_Id" DataType="System.Int32"
HeaderText="Discussion Id" ReadOnly="True" SortExpression="Discussion_Id"
UniqueName="Discussion_Id" Visible="false" >


<telerik:GridTemplateColumn UniqueName="Discussion_Date" HeaderText="Discussion date"
SortExpression="Discussion_Date" ItemStyle-Width="100">
<%# showDiscussionDate(Container.DataItem) %>&nbsp;<%# showDiscussionTime(Container.DataItem) %>
<ClientSettings EnableRowHoverStyle="true"></ClientSettings>

public string showDiscussionDate(object dataItem)
string retDate = string.Empty;
string inDate = string.Empty;
inDate = DataBinder.Eval(dataItem, "discussion_date").ToString();
retDate = clsUtility.returnDateFormat(inDate);
return retDate;

public string showDiscussionTime(object dataItem)
string retTime = string.Empty;
string inTime = string.Empty;
inTime = DataBinder.Eval(dataItem, "Discussion_Time").ToString();
//retTime = clsUtility.returnTimeFormat(inTime);
retTime = inTime;
return retTime;

Any idea , how to resolve this problem?

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 14 Oct 2010, 10:13 AM
Hi Debashis Pyne,

In order to allow filtering for GridTemplateColumn you need to do the following things:
  • Set the AllowFilteringByColumn property of the grid or table view to True. This is needed to enable filtering.
  • Ensure that the AllowFiltering property of the template column is True (this is the default value).
  • Set the DataField property of the template column to the field you want to use for filtering.

The last point is particularly important since it actually enables the grid to do a specific filtering on a field from the datasource. In your case you might set the DataField property to discussion_date or discussion_time fields from the data source. For more information on this subject please refer to the following help topic and live demo.
Of course you can also create your custom filter using the filter template of the template column and handle the filtering logic yourself.

All the best,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
Debashis Pyne
Top achievements
Rank 1
Answers by
Telerik team
Share this question