Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
You don't need to loop through all the categories, you could just do a Get():
var categoryRepository = ServiceLocator.Current.GetInstance<CategoryRepository>(); var targetCategory = categoryRepository.Get("Sample name");
Assign the values like this:
newsPage.Category = new CategoryList(); newsPage.Add(targetCategory);
By the way, it looks like you are creating a single page, and then assigning the values over and over to it. You'll probably have other issues with your code, but I'm sure you'll figure it out :-)
Hi,
I was wondering how can I set a category for a ContentPage. I have the following code but when I try to assign a value to category it gives me the following error:
Cannot implicitly convert type 'EPiServer.DataAbstraction.Category' to 'EPiServer.Core.CategoryList' Pure.Core
And here is my code:
(in this line I have the issue: newsPage.Category = targetCategory;)