Sorry, I didn't complete my post below before clicking the send button.
Here is a completed version
I have a business object with two public properties - "OrganizationID" and
"OrganizationName". Pretty typical. We will call it Organization.
And I have a collection object which is an arraylist that stores a
collection of the business object described above. Let's call it
Organizations
I have a lstbox control. So I bind it Organizations to the listbox control.
lstSelectedOrgs.DataSource = null;
lstSelectedOrgs.ValueMember = "OrganizationID";
lstSelectedOrgs.DisplayMember = "OrganizationName";
lstSelectedOrgs.DataSource = Organizations;
I initially populate the control. Then I have a way to remove an item. And
then I bind it again.
At some point, all of a sudden, what shows up in the list box looks like
this.
MyNameSpace.Organization
MyNameSpace.Organization
MyNameSpace.Organization
MyNameSpace.Organization
MyNameSpace.Organization
And the number of the items shown in the control matches what I have inside
the collection. Then when I click on one of the items, it crashes.
Any ideas?
Sooraj PM - 17 Oct 2004 08:37 GMT
Hi
If OrganizationId and OrganizationName are declared as properties then it
will not crash. You might have declared these as public variables.
Regards
Sooraj
Microsoft Community Star
> Sorry, I didn't complete my post below before clicking the send button.
> Here is a completed version
[quoted text clipped - 29 lines]
>
> Any ideas?
Sijin Joseph - 18 Oct 2004 05:05 GMT
Set the valueMember and DisplayMember after setting the DataSource property
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
> Sorry, I didn't complete my post below before clicking the send button.
> Here is a completed version
[quoted text clipped - 29 lines]
>
> Any ideas?