Options

AX2009 EP: Exception when no records in the grid under filte

Oleksnadr_kaOleksnadr_ka Member Posts: 2
edited 2010-06-01 in Dynamics AX
Hello all

I'm trying to make a custom filter just as in video webinar on msdn.
In the top of the grid - list box with two values: "My" and "ALL". On text chenged I call X++ filtering procedure:
{
    QueryBuildDatasource    qbdsInventSerial;
    ;

        if (_index == 1)
        {
            qbdsInventSerial = InventSerial_q.dataSourceName(InventSerial_ds.name());
            qbdsInventSerial.clearRange(fieldnum(InventSerial,HoldByUser));
            qbrMyVehicles = qbdsInventSerial.addRange(fieldnum(InventSerial,HoldByUser));
            qbrMyVehicles.value(curuserid());
            qbrMyVehicles.status(RangeStatus::Open);
            InventSerial_ds.executeQuery();
        }
}

Works fine until there is no records under the filtered ranges. In this case - a big exception:
Specified argument was out of the range of valid values.
Parameter name: index
   at Microsoft.Dynamics.Framework.Data.Ax.DataSetView.GetElement(Int32 index)
   at Microsoft.Dynamics.Framework.Data.Ax.DataSetView.GetCurrent()
   at Microsoft.Dynamics.Framework.Portal.UI.WebControls.AxCurrentRecordDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
   at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
   at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
   at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
   at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()
   at System.Web.UI.WebControls.BaseDataBoundControl.set_RequiresDataBinding(Boolean value)
   at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewChanged(Object sender, EventArgs e)

After this connector is broken, user has to refresh the page to make filter work again.
I see the problem is common for asp.net but I do not have a clue how to fix it in AX EP.

I would appreciate your help.
Thanks.
Sign In or Register to comment.