You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Prevent adding duplicate rows in Syncfusion ASP.NET MVC Grid with custom validation
196
-
197
-
The Syncfusion ASP.NET MVC Grid allows you to enforce constraints to prevent duplicate rows by customizing the validation logic within the Grid setup. This ensures data integrity by restricting duplicate entries in the **OrderID** column.
198
-
199
-
To prevent adding duplicate rows in the Grid, follow these steps:
200
-
201
-
1. Implement Custom Validation: Define the `orderIdCustomValidation` function to check whether the entered **OrderID** already exists in the [DataSource](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_DataSource). This allows editing an existing row without triggering a duplicate error.
202
-
203
-
2. Add Dynamic Validation Rules: Create the `orderIDRules` object to enforce unique **OrderID** values. Dynamically add this rule to the form during the **save** action.
204
-
205
-
3. Handle Validation in the [ActionBegin](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ActionBegin) event: In the `ActionBegin` event, check if the **requestType** is **save**. Apply the validation rule before saving and cancel the action `args.cancel = true` if the validation fails.
206
-
207
-
For server-side validation to prevent adding duplicate rows, you can refer to the detailed guidance provided in our [knowledge base](https://support.syncfusion.com/kb/article/11608/how-to-do-server-side-validation-for-grid-in-asp-net-mvc-application). If you want to display the Grid's validation tooltip instead of the alert used in our knowledge base, you can call the `grid.editModule.formObj.validate()` method in the `Ajax/Fetch` success function to display the Grid's tooltip validation for the server side.
208
-
209
-
{% tabs %}
210
-
{% highlight razor tabtitle="CSHTML" %}
211
-
{% include code-snippet/grid/edit/prevent-add-duplicate/razor %}
212
-
{% endhighlight %}
213
-
{% highlight c# tabtitle="Edit-temp.cs" %}
214
-
{% include code-snippet/grid/edit/prevent-add-duplicate/customvalidation.cs %}
Performing CRUD (Create, Read, Update, Delete) actions externally in the Syncfusion<supstyle="font-size:70%">®</sup> Grid allows you to manipulate grid data outside the grid itself. This can be useful in scenarios where you want to manage data operations programmatically.
## Prevent adding duplicate rows with custom validation
339
+
340
+
The Syncfusion ASP.NET MVC Grid allows you to enforce constraints to prevent duplicate rows by customizing the validation logic within the Grid setup. This ensures data integrity by restricting duplicate entries in the **OrderID** column.
341
+
342
+
To prevent adding duplicate rows in the Grid, follow these steps:
343
+
344
+
1. Implement Custom Validation: Define the `orderIdCustomValidation` function to check whether the entered **OrderID** already exists in the [DataSource](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_DataSource). This allows editing an existing row without triggering a duplicate error.
345
+
346
+
2. Add Dynamic Validation Rules: Create the `orderIDRules` object to enforce unique **OrderID** values. Dynamically add this rule to the form during the **save** action.
347
+
348
+
3. Handle Validation in the [ActionBegin](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ActionBegin) event: In the `ActionBegin` event, check if the **requestType** is **save**. Apply the validation rule before saving and cancel the action `args.cancel = true` if the validation fails.
349
+
350
+
For server-side validation to prevent adding duplicate rows, you can refer to the detailed guidance provided in our [knowledge base](https://support.syncfusion.com/kb/article/11608/how-to-do-server-side-validation-for-grid-in-asp-net-mvc-application). If you want to display the Grid's validation tooltip instead of the alert used in our knowledge base, you can call the `grid.editModule.formObj.validate()` method in the `Ajax/Fetch` success function to display the Grid's tooltip validation for the server side.
351
+
352
+
{% tabs %}
353
+
{% highlight razor tabtitle="CSHTML" %}
354
+
{% include code-snippet/grid/edit/prevent-add-duplicate/razor %}
355
+
{% endhighlight %}
356
+
{% highlight c# tabtitle="Edit-temp.cs" %}
357
+
{% include code-snippet/grid/edit/prevent-add-duplicate/customvalidation.cs %}
## Prevent adding duplicate rows in Syncfusion ASP.NET Core Grid with custom validation
196
-
197
-
The Syncfusion ASP.NET Core Grid allows you to enforce constraints to prevent duplicate rows by customizing the validation logic within the Grid setup. This ensures data integrity by restricting duplicate entries in the **OrderID** column.
198
-
199
-
To prevent adding duplicate rows in the Grid, follow these steps:
200
-
201
-
1. Implement Custom Validation: Define the `orderIdCustomValidation` function to check whether the entered **OrderID** already exists in the [dataSource](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_DataSource). This allows editing an existing row without triggering a duplicate error.
202
-
203
-
2. Add Dynamic Validation Rules: Create the `orderIDRules` object to enforce unique **OrderID** values. Dynamically add this rule to the form during the **save** action.
204
-
205
-
3. Handle Validation in the [actionBegin](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ActionBegin) event: In the `actionBegin` event, check if the **requestType** is **save**. Apply the validation rule before saving and cancel the action `args.cancel = true` if the validation fails.
206
-
207
-
For server-side validation to prevent adding duplicate rows, you can refer to the detailed guidance provided in our [knowledge base](https://support.syncfusion.com/kb/article/11608/how-to-do-server-side-validation-for-grid-in-asp-net-mvc-application). If you want to display the Grid's validation tooltip instead of the alert used in our knowledge base, you can call the `grid.editModule.formObj.validate()` method in the `Ajax/Fetch` success function to display the Grid's tooltip validation for the server side.
208
-
209
-
{% tabs %}
210
-
{% highlight cshtml tabtitle="CSHTML" %}
211
-
{% include code-snippet/grid/edit/prevent-add-duplicate/tagHelper %}
212
-
{% endhighlight %}
213
-
{% highlight c# tabtitle="Edit-temp.cs" %}
214
-
{% include code-snippet/grid/edit/prevent-add-duplicate/customvalidation.cs %}
Performing CRUD (Create, Read, Update, Delete) actions externally in the Syncfusion<supstyle="font-size:70%">®</sup> Grid allows you to manipulate grid data outside the grid itself. This can be useful in scenarios where you want to manage data operations programmatically.
## Prevent adding duplicate rows with custom validation
343
+
344
+
The Syncfusion ASP.NET Core Grid allows you to enforce constraints to prevent duplicate rows by customizing the validation logic within the Grid setup. This ensures data integrity by restricting duplicate entries in the **OrderID** column.
345
+
346
+
To prevent adding duplicate rows in the Grid, follow these steps:
347
+
348
+
1. Implement Custom Validation: Define the `orderIdCustomValidation` function to check whether the entered **OrderID** already exists in the [dataSource](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_DataSource). This allows editing an existing row without triggering a duplicate error.
349
+
350
+
2. Add Dynamic Validation Rules: Create the `orderIDRules` object to enforce unique **OrderID** values. Dynamically add this rule to the form during the **save** action.
351
+
352
+
3. Handle Validation in the [actionBegin](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ActionBegin) event: In the `actionBegin` event, check if the **requestType** is **save**. Apply the validation rule before saving and cancel the action `args.cancel = true` if the validation fails.
353
+
354
+
For server-side validation to prevent adding duplicate rows, you can refer to the detailed guidance provided in our [knowledge base](https://support.syncfusion.com/kb/article/11608/how-to-do-server-side-validation-for-grid-in-asp-net-mvc-application). If you want to display the Grid's validation tooltip instead of the alert used in our knowledge base, you can call the `grid.editModule.formObj.validate()` method in the `Ajax/Fetch` success function to display the Grid's tooltip validation for the server side.
355
+
356
+
{% tabs %}
357
+
{% highlight cshtml tabtitle="CSHTML" %}
358
+
{% include code-snippet/grid/edit/prevent-add-duplicate/tagHelper %}
359
+
{% endhighlight %}
360
+
{% highlight c# tabtitle="Edit-temp.cs" %}
361
+
{% include code-snippet/grid/edit/prevent-add-duplicate/customvalidation.cs %}
0 commit comments