private void AddSelectedWebParts() { WebPartZoneBase zone = null; if (base.WebPartManager != null) { zone = base.WebPartManager.Zones[this._selectedZoneID]; } CatalogPart selectedCatalogPart = this.SelectedCatalogPart; WebPartDescriptionCollection availableWebPartDescriptions = null; if (selectedCatalogPart != null) { availableWebPartDescriptions = selectedCatalogPart.GetAvailableWebPartDescriptions(); } if (((zone != null) && zone.AllowLayoutChange) && ((this._selectedCheckBoxValues != null) && (availableWebPartDescriptions != null))) { ArrayList webParts = new ArrayList(); for (int i = 0; i < this._selectedCheckBoxValues.Length; i++) { string str = this._selectedCheckBoxValues[i]; WebPartDescription description = availableWebPartDescriptions[str]; if (description != null) { WebPart webPart = selectedCatalogPart.GetWebPart(description); if (webPart != null) { webParts.Add(webPart); } } } this.AddWebParts(webParts, zone); } }
private void AddSelectedWebParts() { WebPartZoneBase selectedZone = null; if (WebPartManager != null) { selectedZone = WebPartManager.Zones[_selectedZoneID]; } CatalogPart selectedCatalogPart = SelectedCatalogPart; WebPartDescriptionCollection availableWebParts = null; if (selectedCatalogPart != null) { availableWebParts = selectedCatalogPart.GetAvailableWebPartDescriptions(); } if (selectedZone != null && selectedZone.AllowLayoutChange && _selectedCheckBoxValues != null && availableWebParts != null) { ArrayList selectedWebParts = new ArrayList(); // Fetch all of the WebParts before calling AddWebPart() on any of them. // This is necessary if the CatalogPart would refresh its list of // AvailableWebPartDescriptions in response to adding a WebPart. // PageCatalogPart is an example of this. (VSWhidbey 337539) for (int i = 0; i < _selectedCheckBoxValues.Length; i++) { string value = _selectedCheckBoxValues[i]; WebPartDescription webPartDescription = availableWebParts[value]; if (webPartDescription != null) { WebPart part = selectedCatalogPart.GetWebPart(webPartDescription); if (part != null) { selectedWebParts.Add(part); } } } AddWebParts(selectedWebParts, selectedZone); } }