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"))
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.
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.
is there any other way to do this? I must need to add "--Select--" as an item in the dropdown.
Thanks Mike for the quick response. I would like the "Please Select.." as an item on the list so I was able to accomplish what I wanted using your suggestion of adding the items from my datasourse in a loop. Thanks for pointing me in the right direction.