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

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?

share|improve this question
    
Did you manage to solve this? I'm currently having the same problem. Gary. –  user6766 Feb 7 '12 at 10:48

2 Answers 2

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>

share|improve this answer

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.

share|improve this answer

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.