Show / Hide Table of Contents

    IDataStoreBase.RowsMove(int startrow, int endrow, DwBuffer movebuffer, IDataStoreBase targetdw, int beforerow, DwBuffer targetbuffer) Method

    .NET Standard 2.x

    Clears a range of rows from one DataStore and inserts them in another. Alternatively, RowsMove can move rows from one buffer to another within a single DataStore.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

      public bool RowsMove(int startrow, int endrow, DwBuffer movebuffer, IDataStoreBase targetdw, int beforerow, DwBuffer targetbuffer);
    

    Parameters

    startrow System.Int32

    The zero-based index number of the first row you want to move.

    endrow System.Int32

    The zero-based index number of the last row you want to move.

    movebuffer DWNet.Data.DwBuffer

    A value of the DwBuffer enumerated datatype identifying the DataWindow buffer from which you want to move the rows.

    targetdw DWNet.Data.IDataStoreBase

    The name of the DataStore to which you want to move the rows. targetdw can be the current DataStore or a different DataStore, but it cannot be a DataWindowChild.

    beforerow System.Int32

    The zero-based index number of the row before which you want to insert the moved rows. To insert after the last row, use -1 or use any value that is greater than the number of existing rows.

    targetbuffer DWNet.Data.DwBuffer

    A value of the DwBuffer enumerated datatype identifying the target buffer into which you want to move the rows.

    Returns

    System.Boolean

    Returns true if it succeeds, and false if startrow, endrow or beforerow is not correct.

    Remarks

    When you use the RowsMove method, the rows have the status ModelState.NewModified in the target DataStore.

    If you move rows between buffers in a single DataStore, DataStore retains knowledge of where the rows came from, and changes their status accordingly. For example, if you move unmodified rows from the primary buffer to the delete buffer, they are marked for deletion. If you move the rows back to the primary buffer, their status returns to ModelState.NotModified. Note, however, that if you move rows from one DataStore to another and back again, the row status is ModelState.NewModified because they came from a different DataStore.

    When you use the RowsMove method, data is not automatically retrieved for drop-down DataWindows in the target DataStore, as it is when you call the InsertRow method. You must explicitly call the Retrieve method for DataWindowChilds in the target.

    When you use the RowsCopy method or the RowsMove method to populate another DataStore, the copied data is not automatically processed by filters or sort criteria in effect on the target DataStore. You might be required to call the Filter methods, or Sort methods to properly process the data.

    Uses for RowsMove include:

    • Moving several rows from the primary buffer to the delete buffer, instead of deleting one at a time
    • Moving rows from the delete buffer to the primary buffer, to implement an Undo capability in your application

    Examples

    The following code example deletes the first row and then calls the RowsMove method to restore the deleted row from the delete buffer.

    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStoreBaseExamples
    {
        public class RowsMoveExample
        {
            private readonly SchoolContext _context;
    
            public RowsMoveExample(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);
    
                datastore.Retrieve();
    
                // This datastore has 4 records.
                Console.WriteLine("Retrieved Rowcount: {0}", datastore.RowCount);
    
                // Deletes the first row.
                datastore.DeleteRow(0);
    
                Console.WriteLine("After DeleteRow, Primary buffer Rowcount: {0}",
                                   datastore.RowCount);
    
                Console.WriteLine("After DeleteRow, Delete buffer Rowcount: {0}",
                                   datastore.DeletedCount);
    
                // Calls RowsMove to move all rows from the delete buffer to 
                // the primary buffer
                datastore.RowsMove(0, datastore.DeletedCount, DwBuffer.Delete,
                                   datastore, 0, DwBuffer.Primary);
    
                Console.WriteLine("After RowsMove, Primary buffer Rowcount: {0}",
                                   datastore.RowCount);
    
                Console.WriteLine("After RowsMove, Delete buffer Rowcount: {0}",
                                   datastore.DeletedCount);
    
                /*This code produces the following output:
                
                Retrieved Rowcount:4
                After DeleteRow, Primary buffer Rowcount: 3
                After DeleteRow, Delete buffer Rowcount: 1
                After RowsMove, Primary buffer Rowcount: 4
                After RowsMove, Delete buffer Rowcount: 0
                */
    
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon