I am getting this error message: "Select of a control that is within a container control, such as a gallery, from outside the container. Select can be used within a container control when both controls are within the same container."
I am using the Select(Gallery Name, Row Number) function
to select the gallery and the particular row in the gallery.
Select(SPRGallery, cvSPRGalleryRowNumber);
The Select() function is being executed in the screen's OnVisible event.
The selected row is highlighted using the gallery's TemplateFill property.
But sometimes I get this error message.
Can someone explain why I am getting this error?
But the error does not occur every time.
Thank you, this is very helpful and makes a lot of sense.
The documentation hints at this but is I think in need of correction, as it suggests that the second parameter should be an integer (index of record) whereas you are saying it should be the record itself.
Also to address "because we have no way of telling which instance of the control you want selected", couldn't it assume that if the 2nd and/or 3rd parameters are omitted then it is the Gallery2.Selected record which should determine the record to select, and the gallery's OnSelect event that should be fired?
I got this response from a Microsoft Escalation Engineer if it would help anyone:
The error you're reporting is saying that you cannot do Select() on a control within a gallery, because we have no way of telling which instance of the control you want selected. That control is going to be instantiated for each time in the gallery, so there could be dozens or hundreds of instances of it.
To specify, you need to use the other parameters available for the Select() formula, which let you specify the row and child control to be selected. For example if I want to do Select() on the first instance of Button1 in my gallery, I can do this:
Select(Gallery2, First(Gallery2.AllItems), Button1)
If I want to do Select() on the SelectedItem from the gallery, I can do it this way:
Select(Gallery2, Gallery2.Selected, Button1)
I just started seeing this error as of 4/8 - it was working perfectly on 4/5. New version released?
I am getting the same error. I am also calling the Select(myGallery) in the screen's OnVisible event, but have now tried putting a button into the same container as the gallery (the button and the gallery are siblings in a container), and even pressing this button manually produces the same error. I am not passing a row number. In my case the message always occurs.
Sorry, I don't have a suggestion, but you are not alone.
WarrenBelz
89
Most Valuable Professional
MS.Ragavendar
58
Michael E. Gernaey
42
Super User 2025 Season 1