public SPWebPartConnectionInstance(ObjectInstance prototype, SPWebPartConnection webPartConnection) : this(prototype) { if (webPartConnection == null) { throw new ArgumentNullException("webPartConnection"); } m_webPartConnection = webPartConnection; }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = properties.Feature.Parent as SPWeb; if (web != null) { SPFile file = web.GetFile("Category.aspx"); if (file.Exists) { SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared); System.Web.UI.WebControls.WebParts.WebPart bdcItemBuilder = null; System.Web.UI.WebControls.WebParts.WebPart categoryDetails = null; System.Web.UI.WebControls.WebParts.WebPart childCategoriesWebPart = null; System.Web.UI.WebControls.WebParts.WebPart productsWebPart = null; foreach (System.Web.UI.WebControls.WebParts.WebPart webPart in manager.WebParts) { switch (webPart.Title) { case "Business Data Item Builder": bdcItemBuilder = webPart; break; case "Category Details": categoryDetails = webPart; break; case "Category List": childCategoriesWebPart = webPart; break; case "Product List": productsWebPart = webPart; break; } } ProviderConnectionPoint providerConnection = manager.GetProviderConnectionPoints(bdcItemBuilder)[0]; ConsumerConnectionPoint consumerConnection = manager.GetConsumerConnectionPoints(childCategoriesWebPart)[0]; SPWebPartConnection connection = manager.SPConnectWebParts(bdcItemBuilder, providerConnection, childCategoriesWebPart, consumerConnection); manager.SPWebPartConnections.Add(connection); consumerConnection = manager.GetConsumerConnectionPoints(productsWebPart)[0]; connection = manager.SPConnectWebParts(bdcItemBuilder, providerConnection, productsWebPart, consumerConnection); manager.SPWebPartConnections.Add(connection); consumerConnection = manager.GetConsumerConnectionPoints(categoryDetails)[0]; connection = manager.SPConnectWebParts(bdcItemBuilder, providerConnection, categoryDetails, consumerConnection); manager.SPWebPartConnections.Add(connection); manager.Web.Dispose(); } web.Site.WebApplication.WebConfigModifications.Add(sPWebConfigModification); //Call Update and ApplyWebConfigModifications to save changes web.Site.WebApplication.Update(); web.Site.WebApplication.WebService.ApplyWebConfigModifications(); } }