Show / Hide Table of Contents

    IDataStoreBase.OnRowDeleted(object sender, DwRowChangeEventArgs e) Method

    .NET Standard 2.x

    This method is called after a row in the DataStore has been deleted. It triggers the RowDeleted 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 OnRowDeleted(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 OnRowDeleted method is called when calling Remove, RemoveAt or DeleteRow methods.

    Examples

    The following code example gets the total number of data rows after the data is retrieved, then deletes the first data row, and then gets the total number of data rows again.

    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStoreBaseExamples
    {
        public class OnRowDeletedExample
        {
            private readonly SchoolContext _context;
    
            public OnRowDeletedExample(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 after RemoveAt removed a record.
                datastore.RowDeleted +=
                    (sender, args) =>
                    {
                        // Executes the following code after RemoveAt is executed.
                        Console.WriteLine("Delete the record of first row.");
                    };
    
                // Retrieves rows from the database for datastore.
                datastore.Retrieve();
    
                Console.WriteLine("After Retrieve, Rowcount: {0}",
                    datastore.RowCount);
    
                // OnRowDeleted method is called internally to invoke the 
                // RowDeleted event.
                datastore.RemoveAt(0);
    
                Console.WriteLine("After Delete, Rowcount: {0}",
                    datastore.RowCount);
    
                /*This code produces the following output:
                
                After Retrieve, Rowcount: 4    
                Delete the record of first row.
                After Delete, Rowcount: 3
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon