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

Filtering of a XsltListViewWebPart is absolutely no problem when you change the webPart.XmlDefinition property like this:

                    var xml = new XmlDocument();
             xml.LoadXml(webPart.XmlDefinition); 
            var viewXml = xml["View"]; 
            if (viewXml != null)
             {
                 var viewQuery = viewXml.SelectSingleNode("//Query");

                if (viewQuery != null)
                 {
                     var where = viewQuery.SelectSingleNode("//Where");
                     if (where == null)
                     {
                         where = xml.CreateElement("Where");
                         viewQuery.AppendChild(where);
                     }

                    if (where.ChildNodes.Count == 1)
                     {
                         where.InnerXml = string.Format("<And>{0}{1}</And>", where.FirstChild.OuterXml, query);
                     }
                     else
                     {
                         if (queryCount > 1)
                         {
                             where.InnerXml = string.Format("<And>{0}</And>", query);
                         }
                         else
                         {
                             where.InnerXml = query;
                         }
                     }
                 }} 
webPart.XmlDefinition = xml.InnerXml;

But when the web part is connected to another webpart with a "Send Row of Data To" connection the webPart.XmlDefinition filtering hack doesn’t work any more.

Why?

share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.