Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sharepoint 2013 discussions list has a view named "Flat",but it is uneditable. I have to add aditional fields in the list and display those fields in Flat view. I tried creating another view of Flat view type but that view 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. Is 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);
thisView.Update();

Please give me your feedbacks

Thank You

share|improve this question
    
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?? –  Justin Roy 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. –  Justin Roy 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
show 1 more comment

1 Answer

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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