IDataStoreBase.OnRowDeleting(object sender, DwRowChangeEventArgs e) Method
.NET Standard 2.x
This method is called when a row in the DataStore is about to be deleted. It triggers the RowDeleting event by default, and it can be overridden in a child class of the DataStore.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public void OnRowDeleting(object sender, DwRowChangeEventArgs e);
Parameters
sender System.Object
An event sender in which the event occurred.
It is a reference to the current DataStore by default.
e DWNet.Data.DwRowChangeEventArgs
A DwRowChangeEventArgs object which can be used to pass by event arguments.
Remarks
The OnRowDeleting method is called when calling Remove, RemoveAt or DeleteRow methods.
Examples
The following code example demonstrates how to use the OnRowDeleting method.
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class OnRowDeletingExample
{
private readonly SchoolContext _context;
public OnRowDeletingExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example()
{
// Instantiates a DataStore object with datawindow: d_department.
var datastore = new DataStore("d_department", _context);
// Defines what to do when RemoveAt is deleting a record.
datastore.RowDeleting +=
(sender, args) =>
{
// Executes the following code when RemoveAt is being executed.
Console.WriteLine("Please don't delete me!");
};
// Retrieves rows from the database for datastore.
datastore.Retrieve();
Console.WriteLine("After Retrieve, Rowcount: {0}",
datastore.RowCount);
// OnRowDeleting method is called internally to invoke the
// RowDeleting event.
datastore.RemoveAt(0);
Console.WriteLine("After Delete, Rowcount: {0}",
datastore.RowCount);
/*This code produces the following output:
After Retrieve, Rowcount: 4
Please don't delete me!
After Delete, Rowcount: 3
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x