SaaS CMS has officially launched! Learn more now.

Adding to PropertyDataType enum - Custom properties



I'm using this blog for searching for pages:

Which is terrific, though how would you alter the PropertyDataType property to search for a custom property I develop myself? Choosing PropertyDataType.String isn't changing my resultset!

I've created a custom property which has the property type of 1003. The custom property inherits from the PropertySelectControlBase if that helps?

Thanks very much!


Aug 18, 2009 13:23

Hi Karl!

The PropertyDataType property should match the Type property of the Property class that you have for your custom property (A custom property is made up of both a property and a property control class). This might of course be inherrited from parent controls. For instance, this is the implementation in the PropertyString class:

public override PropertyDataType Type {    get { return PropertyDataType.String; } }
Linus Ekström
Aug 18, 2009 15:14

Hi Linus,

Thanks for your answer!

The resultset isn't being affected by my property however. Last time this happened, it was because I was trying to search for a pagetypeid when I was selecting an integer as a type. It didn't cause any errors, but at the same time it didn't narrow down my resultset.

My property does indeed inherit from PropertyString, though my typeId of my property is 1003.

Any ideas?

Thanks for your help so far!


Aug 18, 2009 17:31

Hi again!

I'm not 100% sure of exacly what it is that you are trying to acomplish but I'll make a guess. You have created a custom property which you have implemented on a page type and want to search for all pages that have this property with a specific value. The code should look something like this in that case:

PropertyCriteria criteria = new PropertyCriteria();
criteria.Name = "[The name of your instanced property on the page type]";
criteria.Condition =
criteria.Type = PropertyDataType.String;
criteria.Value = [Your search value]

If what you are trying to do instead is to find all pages that have a instanced property of your custom type (unregarding of the actual property names) then I'm not sure if that is possible to do actually.

Hope that this helps

Aug 19, 2009 15:26

Hi Linus,

Thanks very much for your comments.

Your first guess is correct.

propEventType.Type = PropertyDataType.String;
propEventType.Condition = EPiServer.Filters.CompareCondition.Contained;
propEventType.Name = "HeadlineClubEventType";
propEventType.Value = type == HeadlineClubType.Club ? "Club" : "Headline";

This code produces "Headline" content regardless of when Club or Headline is specified in the value. Stepping through the code shows no clues either.

I am adding the property to the collection with a value of "Club".

I am executing the search

I am getting a page back with the property containing the value of "Headline".

I'm extremely confused! :(

Do you have any other suggestions?



Aug 20, 2009 12:33

So you're custom property is a dropdown with two values Club and Headline? And they are stored as those strings?

In that case your search should work. I would however use CompareCondition.Equals

Note also that if you search for more propertycriterias then if don't set the Requiered property to true an OR seasrch will be executed.

Aug 20, 2009 13:07

Ah ha!

 Sorry guys, that's what i was doing wrong! I do remember hearing something about ands only being ands when they're required. that was the problem!

Thanks very much for your help. You've saved many many headaches! :-)



Aug 20, 2009 16:40
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.