Combobox & AutoCompleteMode Suggest : Seeking Advice :)

Combobox & AutoCompleteMode Suggest : Seeking Advice :)

Old forum URL: forums.lhotka.net/forums/t/2051.aspx


guyroch posted on Saturday, December 30, 2006

To all eartlings :)

I have a combobox with a ReadOnlyListBase as a datasource. The display member is a string, say Descriptor, and the value member is a Guid, say RegionGuid.

I also have a BusinessBaseBO in which the user must specify a region using the combobox provided. The combobox is binded to my BusinessBaseBO via the SelectedValue property.

This works fine - at least it did until I encountered a use case where it is possible for the user to suggest a value that is not in the list. When he does, the text value suggested must be accepted and the new value (the new region in this case) must be added to the database when the user hits save.

The dilemma I’m facing is this.

When the user suggests a new region, the RegionGuid of the combobox is set to null, which is of course not a valid value for now. In the ‘Validating’ event, I set the BusinessBaseBO RegionGuid property to ‘new Guid()’ and I also set the new region text value to a string property on my BusinessBaseBO still. In my dp_update method of the BusinessBaseBO, when the RegionGuid is equal to the value of ‘new Guid()’ I know I have to not only save my BusinessBaseBO, but that I also have to add the new region as well. Of course I have to reload the region list as well as I now have a new region.  It's working fine, but it does leave me with a not so worm and fuzzy feelings :(

Is this the right thing to do?

How are you guys handling this?

ajj3085 replied on Tuesday, January 02, 2007

That's basically the same thing I'm doing, to satisify the same kind of requirements.  Instead of having a Guid property on the BO though, I usually accept the string and lookup the Guid when the main Bo saves. 

Copyright (c) Marimer LLC