Pointing the ListViewWebPart at a particular view

So yesterday I described adding a ListViewWebPart to a Site Definition. This works – but how do you point the web part at a particular view?

This took a little figuring out. My ListViews were being defined in my ONET.xml file as:

<View List="Comments" BaseViewID="0" WebPartZoneId="Left">

Clearly the BaseViewID was a likely candidate – but what did it point to, and how could I define a view for my ListView? As is stood, My ListView kept appearing as:


Well, BaseViewID isn’t well documented, but it is actually the ID number of a view in the List Definition. I can’t say that I was able to see how to define a view for out ListView within our Site Definition itself.

If we open up our List Definition’s schema.xml file we see:


You can see that each of the views is assigned assigned a BaseViewID. I tried changing my BaseViewID to ‘1’ and my web part’s view changed to:


Great! This show’s the extra column I wanted – but it also shows the toolbar, which I didn’t. I really wanted the Summary Toolbar (the ‘Add new Item’ link, as in the top screenshot), but I’ll describe how I got that tomorrow.

Pointing the ListViewWebPart at a particular view

2 thoughts on “Pointing the ListViewWebPart at a particular view

  1. Yup, a good tip – if you’re getting an error, check the URL your list is under, and what your ListView is pointing at. Often SharePoint creates lists under the ‘/Lists/’ folder in the virtual file system – but you don’t have to.

    (“Comments” in the example above is not in the /Lists/ folder for example)

Leave a Reply

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 )

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.