IDataStoreBase.SetItem(int row, string column, object value) Method
.NET Standard 2.x
Sets the value of a row and column (by column number).
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public bool SetItem(int row, string column, object value);
Parameters
row
System.Int32
The zero-based index number of the row.
column
System.String
The zero-based index number of the column.
value
System.Object
The value to which you want to set at the specified row and column. The datatype of the value must be the same as the datatype of the column.
Returns
System.Boolean
Returns true
if it succeeds.
Examples
The following code example uses the SetItem
method to modify the value for the name column in the last row.
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class SetItemExample
{
private readonly SchoolContext _context;
public SetItemExample(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 rows from the database for datastore.
datastore.Retrieve();
Console.WriteLine("After Retrieve, Rowcount: {0}",
datastore.RowCount);
// Sets the value for the name column in the last row to "New Department"
datastore.SetItem(datastore.RowCount - 1, "name", "Engineering New");
int lastRow = datastore.RowCount - 1;
Console.WriteLine("Gets the original value of name: {0}",
datastore.GetItemString(lastRow, "name", DwBuffer.Primary, true));
Console.WriteLine("Gets the modified value of name: {0}",
datastore.GetItemString(lastRow, "name", DwBuffer.Primary, false));
/*This code produces the following output:
After Retrieve, Rowcount: 4
Gets the original value of name: Mathematics
Gets the modified value of name: New Department
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x