We are working on a solution to use custom query and paging inside a XsltListViewWebPart.

This work,s but the paging does not work:

var doc = new XmlDocument();
var queryNode = doc.SelectSingleNode("//Query");
if (queryNode == null) return;
var whereNode = queryNode.SelectSingleNode("Where");
if (whereNode != null) queryNode.RemoveChild(whereNode);
var newNode = doc.CreateNode(XmlNodeType.Element, "Where", String.Empty);
newNode.InnerXml = query;
((XsltListViewWebPart)part).XmlDefinition = doc.OuterXml;

We also tried this way for paging:

SPDataSource ds = ((XsltListViewWebPart)part).DataSource as SPDataSource;
XmlDocument viewXmlDoc = new XmlDocument();
XmlNode queryNode = viewXmlDoc.DocumentElement.SelectSingleNode("Query");
queryNode.InnerXml = "<Where><In><FieldRef Name='Assigned_x0020_Employee'/><Values><Value Type='User'>name</Value></Values></In></Where>";
ds.SelectCommand = viewXmlDoc.OuterXml;

The problem is that if we click on the paging button to get the next items filtering for a special name all items will be shown and not only further items based on the query string.

Any ideas?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.