Disable view selector menu in ListViewWebPart in SharePoint 2013.

Hi I was facing the issue that has been mentioned in this thread


The view selector menu was not showing up on the custom web part page.

The way we got it working was to extend the XSLTListViewWebPart and set that property though code.

public partial class VisualWebPart1 : System.Web.UI.WebControls.WebParts.WebPart
 // Uncomment the following SecurityPermission attribute only when doing Performance Profiling using
 // the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
 // for production. Because the SecurityPermission attribute bypasses the security check for callers of
 // your constructor, it's not recommended for production purposes.
 // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
 public VisualWebPart1()

protected override void OnInit(EventArgs e)
 private Microsoft.SharePoint.WebPartPages.XsltListViewWebPart myListView;

protected override void CreateChildControls()
 SPSite oSiteCollection = SPContext.Current.Site;
 string listName = "Notification Centre";
 SPWeb oWebSite = SPContext.Current.Web;
 myListView = new Microsoft.SharePoint.WebPartPages.XsltListViewWebPart();
 myListView.Visible = true;
 myListView.EnableViewState = true;
 SPList list = oWebSite.Lists[listName];

myListView.ListName = list.ID.ToString("B").ToUpperInvariant();
 myListView.TitleUrl = list.DefaultViewUrl;
 myListView.WebId = list.ParentWeb.ID;

myListView.ListId = (System.Guid)list.ID;
 myListView.ViewGuid = list.DefaultView.ID.ToString("B").ToUpperInvariant();

myListView.HelpMode = WebPartHelpMode.Modeless;

myListView.DisableViewSelectorMenu = false;
 myListView.InplaceSearchEnabled = true;

myListView.AllowEdit = true;


protected void Page_Load(object sender, EventArgs e)

Hope it helps

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

Please share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.