hello,
In sharepoint list i need to create a view for a list and make it as default view.how?
thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhay ShankerPosted Nov 25, 2013, 6:15 AM
public void createListView()
{
SPSite site = new SPSite("http://servername/testsara");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Tasks"];
SPViewCollection allviews = list.Views;
string viewName = "Test View";
System.Collections.Specialized.StringCollection viewFields = new System.Collections.Specialized.StringCollection();
viewFields.Add("Title");
viewFields.Add("Priority");
string myquery = "
allviews.Add(viewName, viewFields, myquery, 100, true, false);
}
You can also set newly created view as default view
SPView yourView = CurrentList.Views[UserView];
yourView.DefaultView = true;
yourView.Update();
krishnakumar kunaPosted Nov 25, 2013, 8:08 AM
krishnakumar kunaPosted Nov 25, 2013, 8:07 AM