Netferrets Online Blog, Internet Related Programming Solutions, Created in C# .net, VB .net, MS SQL Server Javascript, HTML and CSS. Proving sample solutions to problems found when creating web application solutions.
Wednesday, 10 July 2013
Umbraco Dropdown Multiple(listbox) DataType Pre Values - How to get them
Its really simple, just do the following to bind it to your listbox:
XPathNodeIterator preValueRootElementIterator = umbraco.library.GetPreValues(1092);
preValueRootElementIterator.MoveNext(); //move to first
XPathNodeIterator preValueIterator = preValueRootElementIterator.Current.SelectChildren("preValue", "");
ListItemCollection categoryListItems = new ListItemCollection();
while (preValueIterator.MoveNext())
{
categoryListItems.Add(new ListItem(" " + preValueIterator.Current.Value, preValueIterator.Current.GetAttribute("id", "")));
}
//Bind data to the list
eventscoveredListBox.DataSource = categoryListItems;
eventscoveredListBox.DataTextField = "Text";
eventscoveredListBox.DataValueField = "Value";
eventscoveredListBox.DataBind();
You can find the id from going into the cms and passing the mouse over the node of the data type you want, put that node id in and your good to go.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment