Update after Edit Not working

I have a List of objects and one of the properties on each object is a list of another objects.  To support adding and editing, I have a SfGrid with a dialog edit and in the content of that dialog is a component.  In that component, I have a SfGrid with inline editing and a toolbar.  When clicking the Edit button it puts the row in edit mode.  But when clicking the Update button, it does not take it out of edit mode.  The Add works the same way.  When I add an OnActionFailure event handler, I get the following message:

Unable to cast object of type 'System.Collections.Generic.HashSet`1[signify_custom.Data.Models.UserHistory]' to type 'System.Collections.IList'.

My objects are defined as follows (some properties removed for brevity:

public List<User> Users

public partial class User
{
    [Key]
    public int UserId { get; set; }
    public string Email { get; set; }
    public ICollection<UserHistory> UserHistories { get; set; }
}

public class UserHistory
{
    public UserHistory() { }

    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }
    public int UserId { get; set; }
    public string Type { get; set; }
    [ForeignKey("UserId")]
    public User User { get; set; }
}

The parent grid is bound to @Users.  The component that is in the dialog edit of the parent grid passes the edited User record as a parameter called User.  The child grid in the component is bound to @User.UserHistories.

The Id field of the child grid is defined as a primary key column:

 <GridColumn Field=@nameof(UserHistory.Id) Visible="false" IsIdentity="true" IsPrimaryKey="true" />

What am I doing wrong?

2 Replies

RW Randy Wessels February 16, 2021 05:43 PM UTC

Looks like I cannot use ICollection.  After changing the collection to a List, the update started working.


RN Rahul Narayanasamy Syncfusion Team February 18, 2021 03:47 AM UTC

Hi Randy, 

Greetings from Syncfusion. 

We have checked your query and we need some details to proceed further on this query. So kindly share us the below details, 

  • Full Grid code snippets.
  • Grid DataSource details.
  • Whether did you defined the mentioned property as normal column or foreign key column.
  • Share a simple reproduceable sample if possible.

The above requested details will be helpful for us to validate the issue and provide you with a better solution as early as possible. 

Regards, 
Rahul 


Loader.
Up arrow icon