I'm not entirely sure how to do this, so would appreciate some advice. This might be simple to do (or maybe not)?
I have an Employee Detail View that has a Location property - the site that they work at. This property is naturally bound to the Employee object. I now have a LocationList of LocationInfo objects.
What I want is to convert the Location text box to a combo box, with the data bound to the Location collection and the SelectedValue remaining bound to the Employee object. Additionally this needs to default to the default site within the Location collection.
The reason I am posting is to see whether this is a feasible solution. In most CSLA projects it seems that selection/picker dialogs are used instead...?
Sorry, that was an end of the day post. I've just figured out how to do that
I feel like a newbie developer now...
Hmm, I do have a problem with this...
It seems that the databinding for the list in the combobox will alter the Employees Location property, therefore making the object dirty.
I've tried binding the list before and after the Employee object but suffer the same in both instances. Has anyone done this successfully, and if so then how?
Any advice appreciated! Thanks.
Hi xal,
The code is roughly as follows (in the Load event of the control):
{
locationListBindingSource.DataSource = _locationList;
cboLocation.DataBindings.Add(new Binding("SelectedValue", _employee, "Location");
}
The combo is bound via the locationListBindingSource, with both DisplayMember and ValueMember set to "LocationName" within the collection, and this list is currently populated with two locations:
Location1
Location2
The problem is as such, if the Employee's location is Location1 then everything works fine. However, if it is Site2 then something occurs to make the Employee object dirty. Somehow the combination of the two bindings seems to cause this.
Any ideas?
Copyright (c) Marimer LLC