Table of Contents

Class FieldValueViewModel

Namespace
Dynamicweb.Ecommerce.ProductCatalog
Assembly
Dynamicweb.Ecommerce.dll

Represents a view model for a field value in the product catalog. Used for product fields, product category fields, order fields, order line fields, and product group fields.

[KnownType(typeof(List<FieldOptionValueViewModel>))]
[KnownType(typeof(LinkViewModel))]
[KnownType(typeof(ColorViewModel))]
[KnownType(typeof(FileViewModel))]
public class FieldValueViewModel : FillableViewModelBase
Inheritance
FieldValueViewModel
Inherited Members
Extension Methods

Remarks

The Value property is typed as object because a field can hold fundamentally different kinds of data depending on its Type. The [KnownType] attributes below register the concrete runtime types that Value may contain so that serialization frameworks (WCF DataContract, JSON.NET, System.Text.Json with polymorphism) can round-trip the value correctly without losing type information.

Properties

ListType

Gets or sets the presentation type of the field when Type is "List". Maps to FieldListPresentationType:

ValuePresentation type
1RadioButtonList — single-select, rendered as radio buttons.
2DropDownList — single-select, rendered as a drop-down.
3MultiSelectList — multi-select list box; Value may contain multiple FieldOptionValueViewModel entries.
4CheckBoxList — multi-select, rendered as checkboxes; Value may contain multiple FieldOptionValueViewModel entries.
5TagCloud — multi-select, rendered as a tag cloud; Value may contain multiple FieldOptionValueViewModel entries.
0Not a list field — Type is not "List".
public int ListType { get; set; }

Property Value

int

Name

Gets or sets the name of the field.

public string Name { get; set; }

Property Value

string

SystemName

Gets or sets the system name of the field.

public string SystemName { get; set; }

Property Value

string

Type

Gets or sets the Dynamicweb field type alias (e.g. "List", "Link", "Filemanager"). Use this together with Value to determine how to interpret the value. The extension methods IsList(FieldValueViewModel), IsLink(FieldValueViewModel), IsFile(FieldValueViewModel), and IsColor(FieldValueViewModel) use this property to do that check for you.

public string Type { get; set; }

Property Value

string

Value

Gets or sets the raw field value. The runtime type of this object depends on the field's Type:

Field type / conditionRuntime type of Value
Type == "List" — multi-select or single-select option field List<T> of FieldOptionValueViewModel. Each element represents one selected option and carries Name, Value, and optionally an Image. A single-select field still uses a list with one element. Use GetList(FieldValueViewModel) to retrieve it safely.
Type == "Link" string (the raw link value). Use GetLink(FieldValueViewModel) to get a resolved LinkViewModel with Url, Target, etc.
Type == "Filemanager" string (the file path relative to the Files folder). Use GetFile(FieldValueViewModel) to get a FileViewModel with a resolved path and metadata.
Color field (value starts with #) string (hex color code, e.g. "#FF5733"). Use GetColor(FieldValueViewModel) to get a ColorViewModel with parsed components.
All other scalar field types (text, number, date, checkbox, …) The CLR type that matches the database column: string, int, double, DateTime, bool, or null when the field has no value. DBNull.Value is normalised to null during construction.
public object Value { get; set; }

Property Value

object

Remarks

Prefer the typed extension methods over casting Value directly: GetList(FieldValueViewModel), GetLink(FieldValueViewModel), GetFile(FieldValueViewModel), GetColor(FieldValueViewModel). Call ToString() or TryGetString(IList<FieldValueViewModel>, string, out string?) to get a safe string representation regardless of the underlying type.

Methods

ToString()

Returns a human-readable string representation of the field value.

public override string ToString()

Returns

string
  • For list fields with multiple selected options: a comma-separated string of option names.
  • For list fields with a single selected option: the option name.
  • For all other field types: the value converted to string via ToString(object?).
  • string.Empty if the value is null or an empty list.

Remarks

Internally calls GetCorrectFieldValue(singleOptionNameInsteadOfValue: true) which unwraps a single-item option list to its name string before converting, so single-select list fields render as a plain label rather than a serialized list object.

To top