I wanted one without the choose at all, so a user forced to chose an item from the get go...
Something like...
public class DropDownListNotEmpty : FieldType { private System.Web.UI.WebControls.DropDownList dd; private List<Object> _value; public DropDownListNotEmpty() { this.Id = new Guid("9255717A-BE66-4835-87DF-8B86CE3CA7C4");
this.Name = "DropDownListNotEmpty"; this.Description = "Renders a html select without an empty option"; this.Icon = "dropdownlist.png"; this.DataType = FieldDataType.String; this.AssociatedField = new Field(); dd = new System.Web.UI.WebControls.DropDownList(); _value = new List<object>(); }
public override List<object> Values { get { if (!string.IsNullOrEmpty(dd.SelectedValue)) { _value.Clear(); _value.Add(dd.SelectedValue); } return _value; } set { _value = value; } } public override bool Rendered { get { return base.Rendered; } set { base.Rendered = value; } } public override System.Web.UI.WebControls.WebControl Editor { get { //dd.Items.Add(new ListItem("", "")); if (this.AssociatedField.PreValueSource != null) { foreach (var prevalue in this.AssociatedField.PreValueSource.Type.GetPreValues(this.AssociatedField)) { ListItem li = new ListItem(DictionaryHelper.GetText(prevalue.Value), prevalue.Id.ToString()); dd.Items.Add(li); } }
How to set dropdown list default string
Hi,
the package datatype dropdown list default string is 'Choose...', I want modify then to other string, any idea?
and the datatype (e.g.dropdown list) can I set the default value to it? I know prevalue can add a value, but then looks can not set the default value.
thx alot :)
Unfortunately, this cannot be done using the default dropdown list datatype, you'd have to write your own datatype to do this.
I wanted one without the choose at all, so a user forced to chose an item from the get go...
Something like...
For your purposes think you'll need to add back in and modify the lines
(ones for front end admin, ones for the datatype editor)
is working on a reply...