Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
Add a "Please Select" option to a bound UltraComboEditor
posted

I am using Business Objects with NHibernate to poplulate an UltraComboEditor. The editor is set as a drop down and limited to the list.  I retrieve my List of objects and bind it to the Editor. I would like to provide the user a "Please Select" prompt as the first (Zero Index) of the drop down and am trying to determine the 'best' means to do this. I have attempted to do a UltraComboEditor.Items.Insert(0, New ValueListItem("Choose","Please Select") but recieve an error that the valuelist cannot be altered after bind.  I cannot 'add' it to my intitial list of objects before bind as this will cause error later on in trying to access a non-existant object.  Is there an option besides doing a loop through of my list to do an "Add" to the valuelist?

Here is my current code which is not working

Dim lstFS as IList(Of FieldSystem) = FieldSystemFactory.GetAll()

uceFieldSystem.ValueMember = "FieldSystemId"

uceFieldSystem.DisplayMember = "Name"

uceFieldSystem.DataSource = lstFS

uceFieldSystem.Items.Insert(0, New ValueListItem("Choose", "Please Select a Field System"))

My thanks in advance for help in determining the best means to accomplish this task.

Parents
  • 469350
    Verified Answer
    Offline posted

    Does the "Please Select" text need to be an item on the list? If so, then there's no way to do this other than adding that item to the data source. Or... you could use the control unbound and add the items from your data source in a loop. 

    If the item doesn't need to appear on the list, then maybe all you need to do is set the NullTextLabel. I'm not sure if that works when using DropDownList mode, but I think it might. 

    If not, another option would be to use a DrawFilter or CreationFilter to simply display some text when the Value of the control is null. 

Reply Children