Show / Hide Table of Contents

    DataStoreExtensions.SetValues(string column, int startRow, int endRow, object value, DwBuffer bufferType = DwBuffer.Primary) Method

    .NET Standard 2.x

    Sets the data value for the specified column and the specified range of rows in the specified buffer.

    Namespace: PowerScript.Bridge

    Assembly: PowerScript.Bridge.dll

    Syntax

    public static void SetValues(this IDataStoreBase dataStore, string column, int startRow, int endRow, object value, DwBuffer bufferType = DwBuffer.Primary);
    

    Parameters

    column System.String

    The column where you want to set values.

    startRow System.Int32

    The number of the first row where you want to set values. It starts from 0.

    endRow System.Int32

    The number of the last row where you want to set values. It starts from 0.

    value System.Object

    The data values to be set.

    bufferType DwNet.Data.DwBuffer

    The buffer where the data value will be set.

    Examples

    The following code example demonstrates how to use the SetValues method to set the values of the Name column in the first and second rows in the primary buffer of DataStore.

    using System;
    using DWNet.Data;
    using PowerScript.Bridge;
    using Appeon.ApiDoc.Models;
    
    namespace Appeon.ApiDoc.DataStoreExtensionsExamples
    {
        public class SetValuesExample
        {
            private readonly SchoolContext _context;
    
            public SetValuesExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example2()
            {
                // Instantiates a DataStore object with datawindow: d_department.
                var datastore = new DataStore("d_department", _context);
    
                // Retrieves data.
                datastore.Retrieve();
    
                // Creates a new string array of names.
                string[] names = new string[] { "new_name1", "new_name2", "new_name3", "new_name4" };
    
    
                // Sets the values of Name column in 1st and 2nd rows in DataStore primary buffer.
                datastore.SetValues("Name", 0 , 1, names, DwBuffer.Primary);
    
                for (int i = 0; i < datastore.RowCount; i++)
                {
                    string name = datastore.GetItem<string>(i, "Name");
    
                    Console.WriteLine($"Name={name}");
                }
    
                /*This code produces the following output:
                
                Name=new_name1
                Name=new_name2
                Name=Economics
                Name=Mathematics
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon