Custom DDL DataType prevalues - "text" and "value"
Hello Umbraco Colleagues:
I have a User Control containing a DropDownList. The DDL items come from the prevalues of a custom DataType (type: Dropdown list).
The UC generates a new content node successfully and is *meant* to assign a value to property
- but the property value is not being set.
Here is the relevant code:
int nodeId = 1074; //PayrollPeriod Picker Node Id Document dataType = new Document(nodeId); XPathNodeIterator preValueRootElementIterator = umbraco.library.GetPreValues(nodeId); preValueRootElementIterator.MoveNext(); XPathNodeIterator preValueIterator = preValueRootElementIterator.Current.SelectChildren("preValue", ""); ListItemCollection DDLItems = new ListItemCollection();
while (preValueIterator.MoveNext()) { DDLItems.Add(new ListItem(preValueIterator.Current.Value, preValueIterator.Current.GetAttribute("id", ""))); }
//Bind data to dropdown list DropDownList1.DataSource = DDLItems; DropDownList1.DataTextField = "Text"; DropDownList1.DataValueField = "Value"; DropDownList1.DataBind();
- but I cannot figure out how to read the "text" and "value" from the prevalues. (It seems the "id" of the prevalue will not work.)
Can anyone please tell me how to get "text" and "value" from the prevalues?
Thank you,
David Hill
PS: As a bonus, could someone tell me how to iterate through the prevalues of a custom datatype. Assigning DDL items in a loop would be preferable to assigning the DataSource because I would have more control over the items. Thanks! DfH
Custom DDL DataType prevalues - "text" and "value"
Hello Umbraco Colleagues:
I have a User Control containing a DropDownList. The DDL items come from the prevalues of a custom DataType (type: Dropdown list).
The UC generates a new content node successfully and is *meant* to assign a value to property
- but the property value is not being set.
Here is the relevant code:
I believe the problem is with this part:
- but I cannot figure out how to read the "text" and "value" from the prevalues. (It seems the "id" of the prevalue will not work.)
Can anyone please tell me how to get "text" and "value" from the prevalues?
Thank you,
David Hill
PS: As a bonus, could someone tell me how to iterate through the prevalues of a custom datatype. Assigning DDL items in a loop would be preferable to assigning the DataSource because I would have more control over the items. Thanks! DfH
Thank you very much.
David Hill
is working on a reply...