IDataStore.InsertRow(int row) Method
.NET Standard 2.x
Inserts an empty row to the specified position in the DataStore. If any columns have default values, the row is initialized with these values.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public int InsertRow(int row);
Parameters
row
System.Int32
A value identifying the zero-based row before which you want to insert a row.
Returns
System.Int32
Returns the zero-based number of the row that was added if it succeeds.
Remarks
A newly inserted row (with a status flag of ModelState.New
) is not included in the modified count until the row is populated with data (its status flag becomes ModelState.NewModified
).
Examples
The following code example demonstrates how to insert an empty row before the position specified by a row number.
using Appeon.ApiDoc.Models;
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreExamples
{
public class InsertRowExample
{
private readonly SchoolContext _context;
public InsertRowExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example1()
{
// Instantiates a DataStore object with datawindow: d_department.
var datastore = new DataStore("d_department", _context);
datastore.Retrieve();
Console.WriteLine("Before Insert, Rowcount: {0}", datastore.RowCount);
// Inserts an empty row before the first row of datastore.
datastore.InsertRow(0);
Console.WriteLine("After Insert, Rowcount: {0}", datastore.RowCount);
/*This code produces the following output:
Before Insert, Rowcount: 4
After Insert, Rowcount: 5
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x