1. Issue with WSS3.0 or MOSS2007
After choose "My Task" view of a SPList
The log-on dialog box display
2. Exception with SharePoint Foundation and SharePoint Server 2010
When select a "My Tasks" view of a SPList we see exception
A exception when I run a webpart on a anonymous site with data getting from "My Tasks" view
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
So, Here are two way to solve the issue or exception when getting data from "My Tasks" view with your WebPart, Site Page or Application Page
A. Prevent Log-On issue with WSS3.0 or MOSS 2007
No way until now
B. Solve exception when getting data from "My Tasks" view with SharePoint Foundation 2010 or SharePoint Server 2010
Here is a normal way to get data from a view
SPListItemCollection itemCollection = null;
itemCollection = spList.GetItems(spQuery is a query data from a selected view);
Incase selected view is a "My Tasks" view on a anonymous site so SharePoint 2010 generate exception whenever we access to properties: Count, ListItemCollectionPosition, NumberOfFields, QueryFieldNames, Xml, XmlDataSchema
We know that, so must use try ... catch for getting data codes from a "My Tasks" view. If our purpose is get data with data structure from SPListItems so at catch statement we can use code spList.Items.GetDataTable().Clone(); to get a empty data table with DataTable structure only.
God bless us!
Thomas Trung Vo
No comments:
Post a Comment