I have a site with a Task List, which has a custom Gantt view as the default view. The home page of the site, which is not a wiki page, has a List View Web Part for the Task List where the Gantt view is selected.
When exporting the site as a template and creating a new site from the template, the List View Web Part reverts to the "All Items" list view (although there is no way to verify that this view is actually selected - the Web Part Editor says "Current View"). All other LVWPs on the front page get the correct view.
Trying to fix this, I wrote a snippet of code to first change the view of the LVWP after creating the page (didn't work) and then delete and re-create the web part with the correct view selected:
webPartToAdd.ListName = doclib.ID.ToString("B").ToUpper(); webPartToAdd.ViewGuid = doclib.Views[ganttView_Name].ID.ToString("B").ToUpper();
This does select the right view (the columns in the list view web part matches those in the Gantt view) but the Gantt chart itself doesn't actually display. The list view is a standard view. In order to actually get the Gantt view, I need to manually enter the web part editor, select the Gantt view and refresh the page. So this is obviously a bug. Is there a workaround?