Desktop productivity for business analysts and programmers

Help (TaskSelectedDataControl error)

Reply
Contributor
Posts: 29

Help (TaskSelectedDataControl error)

Hi,

I am creating an EG custom task with more than one input data and [InputRequired] attribute being set to [InputResourceType.None].

In task’s [Show] override method I use the [Consumer.ShowInputDataSelector] to require all input data before showing task form.

There is a [TaskSelectedDataControl] control on the task form that user can use it to filter the dataset.

Here is the problem:

  1. Create a new task on a new EG project.
  2. Select a dataset for input data in the pop-up dialog.
  3. Click the [Edit] button of [TaskSelectedDataControl] control on the task form.
  4. Click the [OK] button of the filter setting dialog.

      

An error occurred say “Can not select a data source. Reason: Index out of range.”.

   

If I ignore the above error and save the task, (the selected input data comes out to the project flow at this time) and open it again and do same processes as above, no error occurs.

   

Is there any way that I can resolve this problem?

Is there any must thing that I missed after calling ShowInputDataSelector?

   

You can reproduce this by making a few changes on SASPress.Examples.RunningTotals:

  1. Task attribute: [InputRequired(InputResourceType.None)]
  2. At beginning of public override ShowResult Show(System.Windows.Forms.IWin32Window Owner) insert following code  

            var cookie = string.Empty;

            var selectedDatasets = Consumer.ShowInputDataSelector(

                null, DataSelectionMode.ReadOnlySingleInput, ServerAccessMode.AnyServer,

                "", "SASHELP", string.Empty, ref cookie) as ISASTaskData2[];

            Consumer.ClearInputData();

            Consumer.AddInputData(selectedDatasets[0]);   


Thanks in advance.

Community Manager
Posts: 2,887

Re: Help (TaskSelectedDataControl error)

Hi,

Be sure to check for null on the selectedDatasets variable before you try to reference it.  If you click Cancel on the data selector, the return will be null. You should then call ClearInputData and AddInputData only if the selectedDatasets != null.

Also, ShowInputDataSelector returns an array of ISASTaskData[], not ISASTaskData2[].  You should probably not try to cast this to ISASTaskData2   The returned object in the array will support ISASTaskData and ISASTaskData2, but the way the interfaces are designed, I would not cast those to other types unless you need the specific ISASTaskData2 methods/properties.

Chris

Contributor
Posts: 29

Re: Help (TaskSelectedDataControl error)

Hi,

Thanks for you answer, but it still not make my problem solved.

Sorry for the incomplete sample code I posted.

Yes, I do confirm the selectedDatasets variable being not null before doing anything further in my real code.

The reason that I cast the return type of ShowInputDataSelector methods to ISASTaskData2[] is for convenience that I will need this later:

1. Get columns of the dataset by using GetColumns() methods of SasData class whose constructor needs a SASTaskData2 type parameter.

2. Set the TaskData property of TaskSelectedDataControl.

I can change both of them to do cast right at it is being used , if it helps, just like the SASPress.Examples.RunningTotals sample shows.

My prolem is, I call Consumer.ShowInputDataSelector to select a data and set it to TaskSelectedDataControl's TaskData property, then in the TaskSelectedDataControl I do nothing but click the OK button, the error message box pops up.

This only occures when I create the task on a new project.

Thanks

Shen

Ask a Question
Discussion stats
  • 2 replies
  • 335 views
  • 0 likes
  • 2 in conversation