locked
Dropdowns display incorrect values when choice list is specified RRS feed

  • Question

  • I have a list of Contacts, and a list of ContactTypes.  There is a many-many relationship between the two using the ContactToContactTypes table. 

    I have set up some queries like "Physician" which returns only those contacts that are physicians using the PreProcess Query on the filter

            partial void Physicians_PreprocessQuery(ref IQueryable<Contact> query)
            {
                query = query.Where(c => c.ContactToContactTypes.Any(ct => ct.ContactType.Name == "Physician"));
            }
    

    Each event is tied to the Contacts table numerous times:  once for Physician, once for Reader,  once for Backup Reader, and once for Company.  (Zero or 1 to Many relationship) So I have Event_Contact, Event_Contact1, Event_Contact2, and Event_Contact3 links between the event table and the Contacts table. 

    I have two Event windows:  CreateNewEvent and EventDetails (to edit an existing event)  I have added the Readers, Physicians, and Companies queries to both screens and set each as the Choice for the appropriate dropdown. 

    Here's the issue: 

    When I open a Create New Event screen - the dropdowns are sometimes displaying data, as if a Physician or Reader is already set. But, it's not.  You just created a new event - all the contacts should be null.  Also, if you save the event, the "contacts that were displayed as if they had been chosen"  are not saved to the database. This is irregular - sometimes 1, 2 or 3 of the 4 dropdowns will incorrectly display a name (though it's always a name that is a valid choice for that dropdown).  This is intermittent and appears to occur most on the first time I open a Create New Event screen for each run, and then the 3 or 4th time I open a Create New Event screen, it doesn't happen. 

    When I open an existing event - the dropdowns likewise will display incorrect data.  I can look in the database and see that the contact is actually null, or the contact is something else other than what is being displayed. 

    But - if I open multiple screens of either the CreateNewEvent or the EventDetail screen - well, I can go back to the first screen that had previously shown incorrect values and it's cleared up.  All screens show the correct values now. 

    I've been googling to no avail.  Does anybody have any ideas? 

    This does not occur if I remove the "Readers", "Physicians" or "Companies" filters from the dropdown and use AUTO as the choices instead. 

    Wednesday, October 1, 2014 6:59 PM

All replies

  • What do you have in the Data Binding Property of the drop downs? 

    Assuming your event entity is called Event, you should have Event.Event_Contact in the data binding property of the first drop down.

    If that's the case, then would it be possible to share your project or create a small repro project?

    Josh

    Friday, October 3, 2014 4:07 PM
  • Event.Reader, Event.Reader2, Event.Physician and Event.Company

    In the Event.lsml table there is this code for each one:

    <NavigationProperty

            Name="Reader"
            Association="Event_Contact"
            FromEnd="Event"
            ToEnd="Contact" />

    I can attempt to make a repro project.  Thanks for the help. 

    Friday, October 3, 2014 4:18 PM