I’ve been looking into a way to have a search web part interface with an OOB ListView web part. I’ve been using SPContext.Current.Web.GetLimitedWebPartManager(), and grabbing the local web part with a PersonalizationScope.User. I am placing the web part on the View’s aspx page, Search.aspx. I am claiming the web part and casting it into a ListViewWebPart. The ListViewWebPart has an attribute listviewxml and viewguid. I’ve tried changing both of these and saving the changes using SPLimitedWebPartManager.SaveChanges() method. I have successfully changed the title of the web part in a personalized view, but the view never changes. Also I’ve successfully changed a Shared View, but this would only allow one person in at a time… I’m looking to either present a dynamic in memory view to the personalized web part or create a personalized view that I can assign a personalized web part to.
On a side note, I’ve worked with the SPGridView control, but trying to get the default context menu’s involved a lot of convoluted javascript in which the AJAX Update Panel caused the script issues. If anyone has found a cleaner more dependable solution for this, please let me know.
taxDocuments.ParentWeb.Site.AllowUnsafeUpdates = true;
taxDocuments.ParentWeb.AllowUnsafeUpdates = true;
SPLimitedWebPartManager currentWebPartCollection = SPContext.Current.Web.GetLimitedWebPartManager("/Tax%20Documents/Forms/search.aspx", PersonalizationScope.User);
ListViewWebPart viewwebpart = (ListViewWebPart)currentWebPartCollection.WebParts[0];
SPView newView = taxDocuments.Views["TheSearch"].Clone("MySearch", 99999, false, false); ;
newView.Title = "MySearch";
//newView.PersonalView = true; //read only property
newView.Query = BuildTaxDocCamlQuery();
newView.Update();
viewwebpart.ViewGuid = newView.ID.ToString();
viewwebpart.ListViewXml = newView.SchemaXml;
viewwebpart.Title = "steve4";
currentWebPartCollection.SaveChanges(viewwebpart);
SPContext.Current.Web.Update();
taxDocuments.ParentWeb.AllowUnsafeUpdates = false;
taxDocuments.ParentWeb.Site.AllowUnsafeUpdates = false;