Spread for ASP.NET 10 Product Documentation
SetValue

Sets a value of the cell at the specified row and column.

Syntax

[JavaScript]

FpSpread1.SetValue(row,column,value,noEvent);

Parameters

row
Integer, row index
column
Integer, column index
value
String, value
noEvent
Boolean, whether to trigger the onDataChanged event

Return Type

None

Remarks

This method sets the value of a cell at the specified row and column and triggers the onDataChanged event if specified. If noEvent is true, the method does not trigger an event; otherwise, the method triggers an onDataChanged event. This method does not cause a postback to occur.

Example 1

This is a sample that contains the method.

On the server side on page load:

Code
Copy Code
FpSpread1.Attributes.Add("onDataChanged", "ProfileSpread()")

On the client side, the script that contains the method would look like this:

JavaScript
Copy Code
<script type="text/javascript">
   function ProfileSpread()
   {
      var szCell = document.all("FpSpread1");
      if (szCell.ActiveCol == 0)
      {
         szCell.SetValue(0,1,"Scott",true);
         alert("Test");
      }
   }
</script>

Example 2

This example maps the onDataChanged event and uses the GetValue and SetValue methods to update the third cell with the sum of the first two cells any time the first or second cell is changed.

JavaScript
Copy Code
<script lang="javascript" type="text/javascript">
  window.onload = function () {
    var spread1 = document.getElementById("<%=FpSpread1.ClientID %>");
    if (document.all) {
// IE
    if (spread1.addEventListener) {
// IE9
    spread1.addEventListener("DataChanged", dataChanged, false);
  } else {
// Other versions of IE and IE9 quirks mode (no doctype set)
    spread1.onDataChanged = dataChanged;
  }
}
  else {
// Firefox
  spread1.addEventListener("DataChanged", dataChanged, false);
  }
}
function dataChanged(event) {
  var rc0=FpSpread1.GetValue(FpSpread1.ActiveRow, 0);
  var rc1=FpSpread1.GetValue(FpSpread1.ActiveRow, 1);
  var res = Number(rc0) + Number(rc1);
  var sVal = ("" + res);
  FpSpread1.SetValue(FpSpread1.ActiveRow, 2, sVal, true);
}
</script>
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options | Documentation Feedback