SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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);
            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?


share|improve this question

How are the querystring values used within the InfoPath forms themselves? You can always use codebehind in the forms to get the querystring values directly, as long as the code isn't Usercode (Sandbox code):

share|improve this answer
I check this option but how can I assign an url param in xmlformview object?? – Xavi Guirao Nov 13 '12 at 15:31

If you use SP Designer to add an InfoPath Form Web Part, the markup contains this:

<WebUI:BrowserFormWebPart runat="server" AllowEdit="True" AllowConnect="True" SubmitBehavior="KeepOpen" ConnectionID="00000000-0000-0000-0000-000000000000" ... ></WebUI:BrowserFormWebPart>

The connection isn't on the XmlFormView webpart at all but on its parent. If you use Reflector (or other decompiler, like Telerik JustDecompile, which is free) you can see that the XmlFormView webpart references its parent when it sets form values through webpart connections.

In OnInit() for the XmlFormView:

this._parentWebPart = this.Parent as BrowserFormWebPart;

The BrowserFormWebPart calls into its child XmlFormView and runs the method SetPartToPartConnections(...), which calls RunWebPartConnections, which calls various databinding methods as required...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.