Question

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);
list.Update();

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();
 }
 response.Close();

 view.SetViewXml(contents);
 view.Title = "My List View";
 view.Update();

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top