Ticket T458563
Visible to All Users

Reproduced Error "Multiple controls with the same ID 'DXEditingRow'"

created 8 years ago

Hello,

In the attached Demo Project you are able to reproduce the "Multiple controls with the same ID 'DXEditingRow -Error".

Start the application and add a new "Group".

Add multiple "Members" to the group but (important!) via Inline Mode, not over the New Button in the Toolbar!!
Save each inserted child Row but not the whole "Group".
Now click the "Edit-Button" of the first Member row.
Now you can see that EACH row get´s in Edit-Mode. If you perform any changes in the first row and try to save you will get the mentioned error!

In my Web-Application i get the error in other constellations as well.

Comments (1)
DevExpress Support Team 8 years ago

    Hello Stefan,

    Thank you for your follow-up.
    I have reproduced the behavior you described.
    I will contact our R&D team regarding this behavior.
    We will get back to you once we have any results or need extra information.  Your patience is appreciated.

    Answers approved by DevExpress Support

    created 8 years ago (modified 7 years ago)

    Hello Stefan,

    We've examined your sample.
    In your project, business classes are inherited from the XPObject class. With this class, Oid is initialized when the object gets saved and this behavior causes the issue you've described (since there are two records without a key value, which is required by the ASPxGridView control). The easiest solution is to change the base class to BaseObject. It allows getting a valid Oid value immediately after creating a new record (DevExpress.Persistent.BaseImpl > BaseObject > OidInitializationMode).
    Please test this solution and let us know whether it meets your needs.

    See Also: Web - How to avoid issues with data-bound controls due to missing or non-unique key values

      Show previous comments (3)
      Dennis Garavsky (DevExpress) 8 years ago

        Hello Stefan,

        Thanks for your update. We certainly agree that using ASPxGridView should not determine your choice of the PK type. We suggested the first solution and asked for your problems with Guid keys just because using the BaseObject > OidInitializationMode property is the easiest way to generate unique keys for your new records, which are important for the ASPxGridView to work correctly.

        Using Guid vs Int32 PK is rather a religious or highly debated in the community question, which is not something I wanted to focus on much here, because both options are very good and are widely used in production. The only real problem with Guid (besides a greater storage size) I am aware of is a possible slowness with INSERTs on large databases due to fragmentariness, but this can still be effectively cured by setting the XpoDefault.GuidGenerationMode property to UuidCreateSequential. Anyway, if you want to use integer PK, that is fine and you will just need to implement another solution for this particular UI scenario.

        The other solution we can offer to you is providing an unique integer key for your record yourself in the AfterConstruction method of your GroupMember  persistent class. It is fully up to you which method do you use to guarantee this condition, e.g. just getting a total count of records +1, a solution from E4904 or even using direct SQL, because this depends on the planned use-case scenario and other project requirements.

        Let me know if you have any further questions on this.

          Hello Dennis,

          thanks for your helpfull hints. I have prefered your last approach. I found out that the easiest way is to assign the CollectionChangedEvent in the Group Object. If the CollectionChangeType is "AfterAdd" i set the Key Value to the collection.Count * (-1)  (*-1 to prevent any conflicts with already existing records) . The "temporary" Key Values will be overwritten later on database side and on client side each record is unique and the aspxgridView works as expected.

          Best regards

          Dennis Garavsky (DevExpress) 8 years ago

            I am happy to hear of your results, Stefan. Do not hesitate to contact us in case of any further difficulties.

            Regards,
            Dennis
            News, tips, tricks and more about DevExpress Application Framework directly from the lab

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.