private static void AddCQWP(SPLimitedWebPartManager webPartManager, string zone, string Url, SPList list)
{
ContentByQueryWebPart CQWP = new ContentByQueryWebPart();CQWP.WebUrl = Url;
CQWP.ListName = list.Title;CQWP.ListGuid = list.ID.ToString();
CQWP.FilterType1 = "Boolean";CQWP.FilterField1 = "Field1";
CQWP.FilterValue1 = "1";CQWP.FilterDisplayValue1 = "1";
CQWP.FilterOperator1 = ContentByQueryWebPart.FilterFieldQueryOperator.Eq;CQWP.FilterType2 = "Boolean";
CQWP.FilterField2 = "Field2";CQWP.FilterValue2 = "1";
CQWP.FilterDisplayValue2 = "1";CQWP.FilterOperator2 = ContentByQueryWebPart.FilterFieldQueryOperator.Eq;
CQWP.Filter1ChainingOperator = ContentByQueryWebPart.FilterChainingOperator.And;
CQWP.Title = "Title of the CQWP";
CQWP.ItemStyle = "TitleOnly";
CQWP.ItemLimit = -1;
CQWP.SortBy = "FieldName";
CQWP.DataMappingViewFields = "FieldName;";
CQWP.WebUrl = "~sitecollection";
CQWP.UseCopyUtil = true;string dataMapping = "LinkUrl:Description:ImageUrl:Title:{" + list.Fields["FieldName"].Id.ToString() + "},FieldName,Text;";
CQWP.DataMappings = dataMapping;
CQWP.DataMappingViewFields = "{" + list.Fields["FieldName"].Id.ToString() + @"},Text;";
webPartManager.AddWebPart(CQWP, zone, 20);}
No comments:
Post a Comment