kamagra how much to take

Using BaseXsltListWebPart and XslListViewWebPart

Working with the . BaseXsltListWebPart sucks, especially when you are trying to use it as a concrete class, extending / changing the way it functions. Everything is sealed or internal, etc. etc. Shock me, shock me with SharePoint. Even if you instantiate an XslListViewWebPart within another WebPart derived class, there are a lot of features that are not available. Most notably, you will lose a bunch of menus.
The best way of doing it is to have a pre-existing BaseXsltListWebPart that already exists. Then you can just loop through the WebParts by using the WebPartManager.WebParts collection, and get a particular WebPart type by using Enumerable.OfType to filter the elements of an IEnumerable based on a specified type, in this case XsltListViewWebPart. Following, we are going to use the XsltListViewWebPart.XmlDefinition property so we can instantiate a new XmlDocument object. After you can execute any changes, then reset the property of the WebPart.

  1. var view = manager.WebParts.OfType<XsltListViewWebPart>().FirstOrDefault();
  2. var xmlDoc = new XmlDocument();
  3. if (view != null) xmlDoc.LoadXml(view.XmlDefinition);
  4. if (xmlDoc.DocumentElement != null)
  5. {
  6. // Do Stuff
  7. }
  8. string xmlDefinition = xmlDoc.OuterXml;
  9. if (view != null) view.XmlDefinition = xmlDefinition;
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>