Is there anyone who knows how to use \"Droplist\" type in template fields?
I guess \"Droplist\" is the same as
The Droplist
is similar to the Droplink
field type in that they are both dropdowns. The Droplist
will only store the name of the item (so it will not have a link to that item), while the Droplink
stores the ID of the item. That means if you rename an option, or move it elsewhere in your Content Tree, the Droplist
will not update (resulting in possible broken links), the Droplink will update.
You can add values to the Droplist
by setting the Datasource
field in the templates to something (for instance /sitecore/content/Home/CSS/
if that's where you would like to store your CSS class names).
You can access the Droplist
in code like so:
Item item = Sitecore.Context.Item;
string css = item["FieldName"]; // Also possible is item.Fields["Fieldname"].Value;
A Droplink
could be accessed like this:
string dropDownItemId = item["Fieldname"]; // Or, again, item.Fields["Fieldname"].Value; if you prefer
var cssItem = Sitecore.Context.Database.GetItem(dropDownItemId); // And now you can
// access any fields in this item.
Edit A good article going into some more detail in the differences between Droplink and Droplist