User Tools

Site Tools


notes:sharepoint2010:listview

ListView in SharePoint

Modify a default view of a list and display it in a ListView control:

<SharePoint:ListView runat="server" ID="ListView1" />
SPWeb web = SPContext.Current.Web;
SPList list = web.Lists["TestList"];
SPView view = list.DefaultView;
 
try
{
    web.AllowUnsafeUpdates = true;
    view.TabularView = false; // hide the left-most column containing checkboxes
    view.Update();
}
finally
{
    web.AllowUnsafeUpdates = false;
}
 
ListView1.ListId = list.ID.ToString();
ListView1.ViewId = view.ID.ToString();
notes/sharepoint2010/listview.txt · Last modified: 2016/10/19 by admin