I followed the link http://www.telerik.com/help/aspnet-ajax/grdfilteringbylisttextfieldforgriddropdowncolumn.html to try to filter a drop down column as below:
<telerik:GridDropDownColumn UniqueName="LocationID" ListTextField="LocationName"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false"
ListValueField="LocationID" HeaderText="Location" DataField="LocationID" ReadOnly="true">
</telerik:GridDropDownColumn>
<telerik:GridBoundColumn DataField="LocationName" HeaderText="LocationName" SortExpression="LocationName"
UniqueName="LocationName" Display="false">
</telerik:GridBoundColumn>
and have the item command event handler as below:
protected void RadGridUsers_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.FilterCommandName)
{
Pair command = (Pair)e.CommandArgument;
if (command.Second.ToString() == "LocationID")
{
e.Canceled = true;
GridFilteringItem filter = (GridFilteringItem)e.Item;
((filter["LocationName"].Controls[0]) as TextBox).Text = ((filter["LocationID"].Controls[0]) as TextBox).Text;
command.Second = "LocationName";
filter.FireCommandEvent("Filter", new Pair(command.First, "LocationName"));
}
}
}
The only difference is that I have not got a declared data source but binding drop down column by code:
protected void RadGridUsers_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem && !e.Item.IsInEditMode)
{
GridDataItem item = (GridDataItem)e.Item;
Literal litrl = (Literal)item["LocationID"].Controls[0];
CommonDataService commonDataService = new CommonDataService();
object dataBindingResult = DataBinder.Eval(item.DataItem, "LocationID");
if (dataBindingResult != null)
{
litrl.Text = commonDataService.LocationGetById(Int32.Parse(dataBindingResult.ToString())).LocationName;
}
}
}
When I try to filter Location column, it always brings back all records.
Cheers
William