2

我以编程方式通过查询 Web 部件构建了一个内容。问题是当我部署解决方案时,Web 部件不会自动更新项目。我必须去“编辑 webpart”,然后 push ok,仅此而已。然后它会更新,我可以看到我的物品。正如您在下面的代码中看到的那样,我尝试过使用UseCatch = false,但它不起作用:

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);
} 
4

0 回答 0