Re: Adding new items to Combobox (MS Access - NotInList)

Re: Adding new items to Combobox (MS Access - NotInList)

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


ozitraveller posted on Monday, June 18, 2007

Hi

I'm hoping some can help me, I want to be able to dynamically add new items to a combobox list.

The reason being, that the current vb6 app does it and the users still want it. The vb6 reference tables only have a text value (single field table), to the text value is written to the main table as well. I just don't like this design, it leads to inconsistent data, which makes grouping in reports difficult.

Will this be a problem using Csla? Would this be a problem when moving to ASP.Net?

I'd appreciate any suggestions/comments.

Thanks

 

RockfordLhotka replied on Monday, June 18, 2007

If you are using data binding, the data in the combobox comes from an object - typically a name/value list.

The NameValueListBase class helps you build this type of list, and it has a protected property called IsReadOnly. Normally you set this to false, load the list with data, set it to true and leave it at true for the life of the object. However, there's no reason you couldn't implement a method that set the value to false, added an item and set it to true.

However, the real question you need to consider is whether these dynamically added items stick around forever, or just for the single run of the app. If forever, then you need to use some object (a command object perhaps) to also add the item to the database. If for a single run, in a Windows app that's easy. In a web app you need to store the modified list somewhere (probably Session) so it sticks around as long as the user is active.

ozitraveller replied on Tuesday, June 19, 2007

Thanks Rocky.

Copyright (c) Marimer LLC