Dev2.Runtime.ServiceModel.Data.Recordset.SetValue C# (CSharp) Method

SetValue() public method

Sets the value of the field at the given field index in the given row. A new row is added if record is null. A new field is added if fieldIndex is greater than or equal to Fields count.
public SetValue ( RecordsetRecord &record, int fieldIndex, string value ) : void
record RecordsetRecord The record to be updated; may be null.
fieldIndex int The index of the field to be updated.
value string The value.
return void
        public void SetValue(ref RecordsetRecord record, int fieldIndex, string value)
        {
            if(record == null)
            {
                record = NewRecord();
                Records.Add(record);
            }

            var cell = new RecordsetCell
            {
                Name = record.Label + "." + Fields[fieldIndex].Alias,
                Label = Fields[fieldIndex].Alias,
                Value = value
            };
            if(fieldIndex >= record.Count)
            {
                record.Add(cell);
            }
            else
            {
                record[fieldIndex] = cell;
            }
        }

Same methods

Recordset::SetValue ( int recordIndex, int fieldIndex, string value ) : void

Usage Example

 public void SetValueWithRecordNotExistiongExpectedAddANewRecordToRecordset()
 {
     var rs = new Recordset { Name = "MyRec" };
     rs.Fields.Add(new RecordsetField { Name = "MyField", Alias = "MyField" });
     rs.SetValue(0, 0, "MyTestData");
     Assert.AreEqual("MyTestData", rs.Records[0][0].Value);
 }
All Usage Examples Of Dev2.Runtime.ServiceModel.Data.Recordset::SetValue