Telerik Radgrid Filtering Error

When trying to filter my RadGrid using the built in filtering options, I kept getting an exception on the server:

  Stack: System.ArgumentOutOfRangeException:
  Specified argument was out of the range of valid values.
  Parameter name: index
  at System.Web.UI.ControlCollection.get_Item(Int32 index)
  at Telerik.Web.UI.GridTemplateColumn.GetCurrentFilterValueFromControl(TableCell cell)
  at Telerik.Web.UI.GridColumn.RefreshCurrentFilterValue(GridFilteringItem filteringItem)
  at Telerik.Web.UI.GridFilterCommandEventArgs.ExecuteCommand(Object source)
  at Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e)
  at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
  at Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e)
  at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
  at Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e)
  at Telerik.Web.UI.GridItem.FireCommandEvent(String commandName, Object commandArgument)
  at Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Doing some research I found one guy who solved this problem by removing a duplicate UniqueName on his columns, but unfortunately I didn’t have any duplicates :(.

Turned out that the problem was I, in an effort to disable filtering for some columns that should have a filter option, had stumbled upon a quick solution, which was to use the following markup in my template column:

<FilterTemplate />

Instead of:

AllowFiltering="False"

Having the empty filter template seemed to do the trick visually, but it was causing the errors under the covers.

So if you are getting the error above make sure you are dealing with filters in your template columns correctly.

 

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s