We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Deleting an item clears the datasource

Hello,


I am using the Datagrid component at my page and the only actions I have enabled is the Add and the Delete actions.

My problem is that when I try to delete an item from the list then the list is cleared and every item is deleted.
I saw your examples and I have set the AllowDeleting parameter as true but the problem still exists.

I am posting below the datagrid implementation from my project to show you the problem.


Any ideas on how to solve this?

Thanks in advance!




Attachment: DatagridTesting_7743c4de.zip

1 Reply 1 reply marked as answer

PS Prathap Senthil Syncfusion Team February 14, 2023 08:27 AM UTC

Hi Amanda,

Thank you for reaching out to us.


Query:” My problem is that when I try to delete an item from the list then the list is cleared and every item is deleted.”

After reviewing the provided sample, it seems that you have used the same name for the primary column multiple times, which is causing the problem of deleting all items from the list. To resolve this, we recommend using the primary key column for unique values. You can do this by setting the IsPrimaryKey property to true for a particular column whose value is unique. Please refer to the attached documentation for more information.

Note:

Editing feature requires a primary key column for CRUD operations.
To define the primary key, set 
IsPrimaryKey to true in a particular column whose value is unique.


Documentation: https://blazor.syncfusion.com/documentation/datagrid/editing


Regards,
Prathap S


Marked as answer
Loader.
Up arrow icon