I built a content by query web part programmatically. The problem is that when I deploy the solution, the web part doesn't update the items automatically. I must go to "edit webpart" and just push ok, nothing more. Then it updates and I can see my items. I have tried using UseCatch = false
, as you can see in my code below, but it's not working:
public void contentQuery(SPWeb web, SPList list)
{
ContentByQueryWebPart queryWP = new ContentByQueryWebPart();
//Properties
queryWP.Title = "Aktuella Dokument";
queryWP.ChromeType = PartChromeType.TitleAndBorder;
//Query from list
queryWP.ListName = list.ID.ToString("B").ToUpper();
queryWP.ListGuid = list.ID.ToString("B").ToUpper();
queryWP.WebUrl = web.ServerRelativeUrl;
//Query field
SPField fieldToQuery = list.Fields.GetFieldByInternalName("Aktuellt");
string fieldAsString = fieldToQuery.ToString();
string FieldValue = fieldToQuery.DefaultValue;
//queryWP.ListsOverride = fieldAsString;
queryWP.AdditionalFilterFields = fieldAsString;
queryWP.FilterField1 = fieldAsString;
queryWP.FilterOperator1 = ContentByQueryWebPart.FilterFieldQueryOperator.Eq;
queryWP.FilterValue1 = FieldValue;
queryWP.InitialAsyncDataFetch = true;
queryWP.UseCache = false;
AddWebPart(queryWP, web, "TopColumnZone", 0);
}