Sharepoint 2013 discussions list has a view named "Flat", but it is uneditable. I have to add additional fields in the list and display those fields in Flat view. I tried creating another view of Flat view type but that view is also not displaying the fields that I marked.

So is there is a way to clone this view as editable? I tried cloning that view but the view that is getting created also cannot be edited. This is the code I used to clone the view:

SPSite site = new SPSite("url");
SPWeb web = site.OpenWeb();
SPList List = web.Lists["Discussions List"];
SPView thisView = List.Views["Flat"];
thisView = thisView.Clone("Testing", 100, true, false);

Please give me your feedbacks

Thank You

  • Are you getting error in this code? If yes, which type of error... – Viraj Gorajia Jan 21 '13 at 8:15
  • @Viraj Gorajia above code is working. Problem is im cloning a view that cannot be edited so the view getting created also uneditable. Is there is a way to clone this uneditable view as a editable view?? – Roy Justin Jan 22 '13 at 10:36
  • I tried your code. It is working. but i am not able to see another view like flat view, testing vie. Because Subject view is top level view. When open another view, it redirect to subject view(AllItems.aspx). – Viraj Gorajia Jan 22 '13 at 11:06
  • 1
    @Viraj Gorajia yeah you are right, to view the Flat view you first go to Manage discussions and click a discussion that you created so it'll display all the replies of that specific discussion in Management view there you can change the view to Flat view. – Roy Justin Jan 22 '13 at 11:21
  • Thanx @Justin Roy, Your problem is that you have no seen field which is added in flat view? – Viraj Gorajia Jan 22 '13 at 11:35

Try this code...

Write code in code ascx.cs file

Deploy this solution.. And add this web part.. One view is created shown as "Discussion". It will show all fields which are added in Flat view.

Discussion View

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.