I'm in the process of creating a sandboxed web part, during debugging though once it is on the site the web part displays the error shown below:
Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred.
Now I've searched for this error but have thus far found little information. I've checked the list of restrictions, but I'm pretty sure I'm ok there unless System.Web.UI.Controls is not allowed. You can find my code below and any help would be appreciated.
using System.ComponentModel;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Data;
namespace FPContentQueryCustom.FrontCusWebPart
{
[ToolboxItemAttribute(false)]
public class FrontCusWebPart : System.Web.UI.WebControls.WebParts.WebPart
{
public FrontCusWebPart()
{
}
protected override void CreateChildControls()
{
SPWeb thisWeb = SPContext.Current.Web;
SPListCollection siteLists = thisWeb.Lists;
siteLists.ListsForCurrentUser = true;
DataTable dt = new DataTable();
dt.Columns.Add("data");
foreach (SPList list in siteLists)
{
SPListItemCollection listItem = list.Items;
foreach (SPListItem item in listItem)
{
dt.Rows.Add(item.DisplayName);
}
}
dt.AcceptChanges();
SPGridView grid = new SPGridView();
grid.ID = "ExampleGrid";
grid.AutoGenerateColumns = false;
BoundField col = new BoundField();
col.DataField = "data";
col.SortExpression = "data";
col.HeaderText = this.DisplayTitle;
grid.Columns.Add(col);
grid.DataSource = dt;
grid.DataBind();
Controls.Add(grid);
}
}
}