I'm trying to get the default view url of standard document library list in SP2010:
var defaltViewUrl = documentLibrary.Forms[PAGETYPE.PAGE_DEFAULTVIEW].Url;
and I'm constantly getting the following exception:
ArgumentNullException: "Value cannot be null. Parameter name: formType"
while PAGETYPE.PAGE_DEFAULTVIEW enum value is definitely not null. Any ideas what am I'm doing wrong?
The default view of a list is not stored in the form collection (
SPList.Forms
).So you indeed have to get the url of
SPList.DefaultView.Url
:The
ArgumentNullException
occurs since SharePoint is converting thePAGETYPE.PAGE_DEFAULTVIEW
to string. SincePAGE_DEFAULTVIEW
is not a valid form it's converted tonull
.