1

The situation is the following. I'm creating an XsltListViewWebPart during the Page LifeCycle which is added to the page Controls collection (or UserControl Controls collection). The XsltListViewWebPart is displayed as expected. The only problem is that when an item is selected, the "List Tools" ribbon tab is not available (not visible).

XsltListViewWebPart lvwp = new XsltListViewWebPart();    
SPWeb thisWeb = SPContext.Current.Web;
SPList list = thisWeb.GetList(SPUtility.ConcatUrls(thisWeb.ServerRelativeUrl, "lists/" + listName));
SPView view = list.DefaultView;
lvwp.ListId = list.ID;
lvwp.ViewGuid = tabView.ID.ToString("B").ToUpperInvariant();
lvwp.ItemContext = SPContext.GetContext(this.Context, view.ID, list.ID, thisWeb);
lvwp.ShowToolbarWithRibbon = true;    
this.Controls.Add(lvwp);

What am I missing?

1
  • Did you manage to solve this? I'm currently having the same problem. Gary.
    – user6766
    Commented Feb 7, 2012 at 10:48

2 Answers 2

1

I found that the only way to show XsltListViewWebPart ribbon is to add dynamic created webpart to:

<WebPartPages:WebPartZone runat="server" ID="MainZone">
    <ZoneTemplate>

    </ZoneTemplate>

0

Is your webpart toolbar mode configured as Full? I suppose it may be the case - SharePoint doesn't apply the Ribbon customizations to the list if the webpart toolbar is in Summary mode. Unfortuntely I don't know how to set it programmatically - just point the direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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