FireCommandEvent fires NullReferenceException

3 posts, 1 answers
  1. Yazid
    Yazid avatar
    3 posts
    Member since:
    Apr 2015

    Posted 15 Aug Link to this post


    i try to perform filter operation programmatically. So i created an asp button and attached a server side click event handler. The filter operation should be fired in the event handler:

     protected void Filter_Click(object sender, EventArgs e)
                RadGrid grd = grid;
                grid.MasterTableView.FilterExpression = "([Capture] LIKE 'Kind%')"; // Capture is the id and unique name of a GridBoundColumn
                GridColumn column = grid.MasterTableView.GetColumnSafe("Capture");
                column.CurrentFilterFunction = GridKnownFunction.Contains;
                column.CurrentFilterValue = "Kind";
                grd.EnableLinqExpressions = false;
                GridDataItem item = (grid.MasterTableView.GetItems(GridItemType.Item)[2] as GridDataItem);
                item.FireCommandEvent("Filter", new System.Web.UI.Pair("Kind", "Capture")); // exception is being fired at this line


    This code causes an exception:


    An exception of type 'System.NullReferenceException' occurred in Telerik.Web.UI.dll but was not handled in user code

       at Telerik.Web.UI.GridColumn.RefreshCurrentFilterValue(GridFilteringItem filteringItem, String functionName)
       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 Lusd.Presentation.LusdApplication.UserControls.Schule.InstitutionsListeControl.Filter_Click(Object sender, EventArgs e) in C:\TFS\ZeGOV\LUSD\Client\development\standard\Presentation\Presentation.LusdApplication\UserControls\Schule\InstitutionsListeControl.ascx.cs:line 429
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


    How can I get it fixed?


    Thanks in advance

  2. Answer
    Viktor Tachev
    Viktor Tachev avatar
    1488 posts

    Posted 16 Aug Link to this post

    Hello Yazid,

    Please try to use the approach described in the article below in order to filter the RadGrid from an external button. Give the approach a try and see how it works for you.

    Viktor Tachev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Yazid
    Yazid avatar
    3 posts
    Member since:
    Apr 2015

    Posted 16 Aug Link to this post

    Thank you very much.

    I found also another solution:

    protected void Filter_Click(object sender, EventArgs e)

                grid.MasterTableView.FilterExpression = "([Institution] LIKE \'Hasen%\')";
                GridColumn column = grid.MasterTableView.GetColumnSafe("Institution");
                column.CurrentFilterFunction = GridKnownFunction.Contains;
                column.CurrentFilterValue = "Hasen";
                grid.EnableLinqExpressions = false;
                GridFilteringItem filterItem = grid.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem;
                filterItem.FireCommandEvent("Filter", new System.Web.UI.Pair("Contains", "Capture"));

Back to Top