SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a custom view for a list with custom UI. The following is my code:

list.Views.Add("List View", coll, Query, 10, true, false);

SPView view = list.Views["List View"];

string contents = string.Empty;
WebRequest request = WebRequest.Create(SPContext.Current.Web.Url+"/_layouts/CustomViews/CustomBoxed.xml");
request.Credentials = CredentialCache.DefaultCredentials;
WebResponse response = request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
       contents = reader.ReadToEnd();

 view.Title = "My List View";

The code is basically creating a view in the list, then updating the XML inside the view to display something different. However, on view.Update() I get this error: Cannot complete this action. Please try again

What I'm trying to accomplish: Show an entirely different UI to display the list items. I have gotten copy of the sharepoint VWSTYLES.XML and have used their styles, but that doesn't seem to work.

Thanks! And sorry if this question is a bit confusing.

share|improve this question
Can you verify the contents of the "CustomBoxed.xml" file to which you're making the WebRequest are correctly being assigned to the variable contents? Can you share the contents of that file with us? – Danny Jessee May 29 '12 at 22:28
SetViewXML isn't suppose to be the XSLT, it contains an XML for the view, defining the fields, etc. There is no way to customize the XSLT of a view. I've done extensive research on that. – Umm.... May 31 '12 at 20:43
up vote 0 down vote accepted

I found a work around: The List I want my view in, I inject my custom web part on that page. In my custom web part, I hide the fefault listview web part and show my custom UI there. The only issue I have here is that the ribbon loses its tabs. I'll have to fa work around that.

share|improve this answer

Your Answer


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.