My resolution to the close views for lists
If end user closes the web list web part using the X on the right corner the CAML query and some of the properties get modified. Which prevents the view from displaying the data that should be presented?
That does not mean that the view is corrupted nor the web part is close but there is no way to modify the view. There is a hidden property for the SPView class but setting the value to true does not redisplays the view.
Web parts that are close by passing the var contents=1 on the URL has nothing to do with the views that are not displaying. Microsoft mentions installing the SP1 for SharePoint which does nothing in relation to the views. The problem is CAML query gets modified.
In my opinion the views not displaying any data has to do with the migration.
Original CAML query (Broken)
“<View Name=\”{4222E59E-8879-49F7-AB9D-750A261F851C}\” DefaultView=\”TRUE\” Type=\”HTML\” DisplayName=\”All Documents\” Url=\”/sites/AES/Shared Documents/Forms/AllItems.aspx\” Level=\”1\” BaseViewID=\”1\” ContentTypeID=\”0x\” ImageUrl=\”/_layouts/images/dlicon.png\” ><Query><OrderBy><FieldRef Name=\”FileLeafRef\” /></OrderBy></Query><ViewFields><FieldRef Name=\”DocIcon\” /><FieldRef Name=\”LinkFilename\” /><FieldRef Name=\”Modified\” /><FieldRef Name=\”Editor\” /><FieldRef Name=\”LinkCheckedOutTitle\” /></ViewFields><RowLimit Paged=\”TRUE\”>100</RowLimit></View>”
New CAML after creating a new view
“<View Name=\”{8BAFCD7D-B199-445F-8D6C-F9D625E1D08D}\” DefaultView=\”TRUE\” Type=\”HTML\” DisplayName=\”All Documents\” Url=\”/sites/AES/Shared Documents/Forms/AllItems.aspx\” Level=\”1\” BaseViewID=\”1\” ContentTypeID=\”0x\” ImageUrl=\”/_layouts/images/dlicon.png\” ><Query /><ViewFields><FieldRef Name=\”DocIcon\” /><FieldRef Name=\”LinkFilename\” /><FieldRef Name=\”Modified\” /><FieldRef Name=\”Editor\” /><FieldRef Name=\”LinkCheckedOutTitle\” /></ViewFields><RowLimit Paged=\”TRUE\”>100</RowLimit><Aggregations Value=\”Off\” /></View>”
What is the difference in the views.
The original view(broken). The query does not work because of the two “\”
<Query>
<OrderBy>
<FieldRef Name=\”FileLeafRef\” />
</OrderBy>
</Query>
Should be
<Query>
<OrderBy>
<FieldRef Name=”FileLeafRef” />
</OrderBy>
</Query>
Re-Created View – Sample code not for production
SPSite siteUrl2 = new SPSite(textBox1.Text);
SPWeb myWeb = siteUrl2.OpenWeb();
myWeb.AllowUnsafeUpdates = true;
SPList listtoinsert = myWeb.Lists[newValue.Text];
SPView defaultView = listtoinsert.DefaultView;
listtoinsert.Hidden = true;
listtoinsert.OnQuickLaunch = true;
listtoinsert.EnableVersioning = true;
listtoinsert.Update();
listtoinsert.Fields.AddFieldAsXml(“<Field DisplayName=\”NewField\” Type=\”Boolean\” Required=\”FALSE\” Name=\”NewField\” CanToggleHidden=\”TRUE\” Hidden=\”TRUE\”/>”);
// Create new view columns
StringCollection viewFieldCollection = new StringCollection();
// Add field to collection
viewFieldCollection.Add(“DocIcon”);
viewFieldCollection.Add(“Author”);
viewFieldCollection.Add(“LinkFilename”);
viewFieldCollection.Add(“Last_x0020_Modified”);
viewFieldCollection.Add(“Modified_x0020_By”);
viewFieldCollection.Add(“LinkCheckedOutTitle”);
// Create default view query
string defaultQuery = “<OrderBy><FieldRef Name=\”FileLeafRef\” /></OrderBy>”;
// Get default view information and delete
try
{
Guid oldViewId = listtoinsert.DefaultView.ID;
listtoinsert.Views.Delete(oldViewId);
}
catch
{
}
try
{
listtoinsert.Views.Add(“All Items”, viewFieldCollection, defaultQuery, 100, true, true);
listtoinsert.DefaultView.DefaultView = true;
}
catch
{
}
try
{
listtoinsert.Hidden = true;
listtoinsert.OnQuickLaunch = true;
listtoinsert.EnableVersioning = true;
listtoinsert.Update();
} // try
catch (SPException sp) { }
myWeb.Close();
}