Adding items in listbox that is bind to entitycollection

Posts   
 
    
imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 16-Apr-2010 18:33:28   

I have a simple list box that contains some string values. This list box is initially populated by binding to a entity collection (via DataSource property of listbox). However later user will be able to add some values into it also. When I just do a listbox.Items.Add(mystring), this new values never show up in the listbox itself. Any ideas what I am doing wrong? Or may be there are standard patterns for dealing with this type of situation?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Apr-2010 06:03:35   

Is your app a Winform or WebForm? Could you please show the declarative aspx?

David Elizondo | LLBLGen Support Team
imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 19-Apr-2010 17:05:48   

Its a winform

arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 19-Apr-2010 20:06:38   

I think you need to choose binding to a collection or using the items collection. In my experience you can't do both.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 20-Apr-2010 10:23:54   

if you bind to a set using databinding, you can't add a list of values which aren't in the set to choose from. Typical example: the '<none>' value in a combo box in this case: you can't add that to the combobox, as all values in the combobox are obtained by winforms from the datasource.

You may try to add new entities to the databound entityCollection.