I'm working on a project to automatically generate some document libraries and pages. One of these pages I have to put a infopath form webpart and a TextFilter to send to this form some information (a string to indicate to report to autorun query). Where you have the code:
SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
try
{
XmlFormView form = new XmlFormView();
String templateLib = "FormServerTemplates";
String xsnName = report + ".xsn";
form.XsnLocation = String.Format("{0}/{1}/{2}", "~sitecollection", templateLib, xsnName);
manager.AddWebPart(form, "TopZone", 0);
QueryStringFilterWebPart filter = new QueryStringFilterWebPart();
filter.DefaultValue = "TRUE";
filter.QueryStringParameterName = "ENTITY";
filter.FilterName = "execquery";
filter.AllowConnect = true;
manager.AddWebPart(filter, "TopZone", 1);
System.Web.UI.WebControls.WebParts.WebPart addSearch = manager.WebParts[0];
System.Web.UI.WebControls.WebParts.WebPart addDisplay = manager.WebParts[1];
ConsumerConnectionPoint consumerConnection = null;
foreach (ConsumerConnectionPoint point in manager.GetConsumerConnectionPoints(addSearch))
{
if (point.InterfaceType == typeof(IFilterValues))
{
consumerConnection = point; break;
}
}
ProviderConnectionPoint providerConnection = null;
foreach (ProviderConnectionPoint point in manager.GetProviderConnectionPoints(addDisplay))
{
if (point.InterfaceType == typeof(Microsoft.SharePoint.WebPartPages.ITransformableFilterValues))
{
providerConnection = point; break;
}
}
manager.SPConnectWebParts(addSearch, providerConnection, addDisplay, consumerConnection);
}
When I try to do the connection, consumerConnection is empty, So I understand that xmlformview doesn't have any connection to do this "connection". Are there some way to do this page programatically?
Thanks!