Sharepoint 2013 SPView does not bring all items and/or fields
i created a handler to bring me a view, so say i had this url for the view
"http://server/sub1/sub2/Lists/myList/myItems.aspx"
to i sent my view the server relative url
"/sub1/sub2/Lists/myList/myItems.aspx"
and used it to open a new SPSite and SPWeb and get the items, yet i just couldn't get all my items.
yet when i tried by using the SPContext.Site it worked.
i dont know why, but the context of how the SPSite was opened affects the view.
my final code looks like this
using (SPSite tempSite = new SPSite(serverUrl + serverRelativeViewUrl))
{
using (SPWeb getUrlWeb = tempSite.OpenWeb())
{
spwebUrl = getUrlWeb.ServerRelativeUrl;
}
}
using (SPWeb tempWeb = spContext.Site.OpenWeb(spwebUrl))
{
string viewUrl = item.MethodValue;
if (viewUrl.StartsWith("/") == false)
{
viewUrl = "/" + viewUrl;
}
SPView oView;
try
{ oView = tempWeb.GetViewFromUrl(viewUrl);
}
catch (Exception viewEX)
{
Log...
}
...more code...
"http://server/sub1/sub2/Lists/myList/myItems.aspx"
to i sent my view the server relative url
"/sub1/sub2/Lists/myList/myItems.aspx"
and used it to open a new SPSite and SPWeb and get the items, yet i just couldn't get all my items.
yet when i tried by using the SPContext.Site it worked.
i dont know why, but the context of how the SPSite was opened affects the view.
my final code looks like this
using (SPSite tempSite = new SPSite(serverUrl + serverRelativeViewUrl))
{
using (SPWeb getUrlWeb = tempSite.OpenWeb())
{
spwebUrl = getUrlWeb.ServerRelativeUrl;
}
}
using (SPWeb tempWeb = spContext.Site.OpenWeb(spwebUrl))
{
string viewUrl = item.MethodValue;
if (viewUrl.StartsWith("/") == false)
{
viewUrl = "/" + viewUrl;
}
SPView oView;
try
{ oView = tempWeb.GetViewFromUrl(viewUrl);
}
catch (Exception viewEX)
{
Log...
}
...more code...
Comments
Post a Comment