Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers 2

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):

http://stackoverflow.com/questions/7430676/how-to-get-querystring-value-in-infopath-forms

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
add comment

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
add comment

Your Answer

 
discard

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.