Hi I get the error 'ListViewWebPart' is a 'namespace' but is used like a 'type'
here is my code i don't know how to fix this any ideas?
namespace TestSolution
{
[Guid("d3425822-6979-476d-a8cb-04de9521d1b4")]
public class TestListViewWebPart : System.Web.UI.WebControls.WebParts.WebPart
{
public TestListViewWebPart()
{
this.ExportMode = WebPartExportMode.All;
}
protected override void CreateChildControls()
{
base.CreateChildControls();
try
{
SPSite site = new SPSite("http://test.local/docs");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["ListName"];
ViewToolBar toolbar = new ViewToolBar();
SPContext context = SPContext.GetContext(this.Context, list.Views["SomeView"].ID, list.ID, SPContext.Current.Web);
toolbar.RenderContext = context;
Controls.Add(toolbar);
// Instantiate the web part
ListViewWebPart lvwp = new ListViewWebPart();
lvwp.ListName = list.ID.ToString("B").ToUpper();
lvwp.ViewGuid = list.Views["SomeView"].ID.ToString("B").ToUpper();
//lvwp.ViewGuid = list.DefaultView.ID.ToString("B").ToUpper();
lvwp.GetDesignTimeHtml();
this.Controls.Add(lvwp);
}
catch (Exception ex)
{
Label lbl = new Label();
lbl.Text = "Error occured: ";
lbl.Text += ex.Message;
this.Controls.Add(lbl);
}
}
protected override void Render(HtmlTextWriter writer)
{
EnsureChildControls();
base.Render(writer);
}
}
}