We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Changes to Spreadsheet.Sheets not updating

Thread ID:





142722 Feb 16,2019 02:51 PM UTC Feb 23,2019 05:01 AM UTC ASP.NET Web Forms 3
Tags: Spreadsheet
Asked On February 16, 2019 04:43 PM UTC

Hi Syncfusion,

I'm developing an ASP.NET web forms website (a newbie). One page has a SpreadSheet control. I don't know JavaScript nor Ajax. Therefore, I do everything in code-behind (VB.NET)
When I change SpreadSheet.Sheets like this, the control displays changes. 

        Dim S1 As New Sheet With {

            .Rows = New List(Of Row) From {

            New Row() With {.Cells = New List(Of Cell) From {

                    New Cell() With {.Value = "123"},

                    New Cell() With {.Value = "456"}




Then the user will change the spreadsheet in UI.
After that, I want to retrieve that changes on postback of a button click.
For that, In the button_click event, I'm trying to get the value of SpreadSheet1.Sheets and use it. But It never changes. It does not get any changes made by the user.

How to retrieve changed in SpreadSheet1.Sheets in postback?
I don't want to save it. I just want do access SpreadSheet1.Sheets object.
(Please I don't want any javascript mess)

I am getting exceptions in the page. Check if they are related - https://www.syncfusion.com/forums/142725/application-error-in-global-asax-when-loading-a-page-containing-spreadsheet-control

Silambarasan I [Syncfusion]
Replied On February 19, 2019 06:35 AM UTC

Hi Hasindu, 
Thank you for contacting Syncfusion support. 
We have checked your reported requirement “Using Cell databinding, to access the spreadsheet’s updated data at server side” and as per our current implementation behavior, your requirement to access the data in server side is not feasible while using cell data binding.  
However, we would suggest you to bind dataSource by using ‘Datasource’ or ‘RangeSettings property in Spreadsheet. And, we have provided ‘onSeverCellSaveserver-side event for cell save which triggers in server side while on saving the edited cell value. Using this event, you can get the modified cell value in server-side on every cell save. Please refer the below demo sample for more details. 
Server Side Save Event: 
Please refer the below help documentation link for about databinding in Spreadsheet: 
Could you please check the above information and get back to us if you need further assistance on this? 

Replied On February 21, 2019 08:18 PM UTC

Hi Syncfusion,

I've worked on your codes and now it's working
I selected onSeverCellSave method to implement.

    Protected Sub Spreadsheet_ServerCellSave(ByVal sender As Object, ByVal e As SpreadsheetEventArgs)

        Dim KeyVal As Dictionary(Of String, Object) = TryCast(e.Arguments, Dictionary(Of String, Object))

        If e.EventType = "cellSave" Then
            Dim rowIdx = Convert.ToInt32(KeyVal("rowIndex"))
            Dim colIdx = Convert.ToInt32(KeyVal("colIndex"))
            Dim value = KeyVal("value")

            Sheet1 = FlatSpreadsheet.Sheets(0)
            Sheet1.Rows(rowIdx).Cells(colIdx).Value = value
            FlatSpreadsheet.Sheets(0) = Sheet1

        End If

        ViewState("DataSource") = DS
        serverEvent.InnerHtml = serverEvent.InnerHtml & span & "cell Save event called
    End Sub

But now, Client has to PostBack each time when changing a cell. It creates a lag even when UpdatePanels are there.
So, How to avoid this lag?
Is there a way to "Bulk update Cell changes" ?
How to restore Spreadsheet scroll and selected cell after a postback happens?
Is there any "sily things" done in above code?
How to avoid fill handler errors when using onSeverCellSave  (Spreadsheet_ServerCellSave only recieve the formulas of first and last cells. Others are evaluated values!)

Thanks for these quick responses.

Silambarasan I [Syncfusion]
Replied On February 23, 2019 05:01 AM UTC

Hi Hasindu, 
Thanks for your update. 
We have checked your reported requirements and we would let you know that as we stated in our previous update “onServerCellSave” event called while saving the each cell. So, we would suggest you to update the bulk edited data to the server side, by using the client side “saveEditingValue” method.  
For your convenience, we have prepared a sample that bind the datasource using rangeSettings property and get the bulk edited data (updated datasource) in the serverside using client-side button click event as like in the below code example. 
<input type="button" value="Save Changes to Server" id="saveChangesToServer" /> 
 <ej:Spreadsheet ID="Spreadsheet1" runat="server"> 
    <ClientSideEvents LoadComplete="loadComplete" OpenFailure="openfailure" /> 
    <ScrollSettings Width="100%" Height="470" IsResponsive="true" /> 
                                <ej:RangeSetting ShowHeader="false" /> 
<script type="text/javascript"> 
$("#saveChangesToServer").on("click", function () { 
//To get the bulk edited data in server side. 
    var ssObj = $("#MainContent_Spreadsheet1").data("ejSpreadsheet"), key, rowIdx, sheetIdx = ssObj.getActiveSheetIndex(), editedChanges = ssObj.XLEdit.saveEditingValue().EditedData, 
        dataSettings = ssObj.getDataSettings(sheetIdx)[0], isShowHeader = dataSettings.showHeader, dataSource = dataSettings.dataSource, changedDataSource = [], pushedRowColl = []; 
    activeCell = ssObj.getActiveCell(sheetIdx); // To get the activeCell for scrolling after post back 
    if (!editedChanges.length) { 
    ssObj.alert ("Please edit any cells and try again!"); 
    for (key in editedChanges) { 
    rowIdx = editedChanges[key].CellIndex.RowIndex; 
    if (isShowHeader) 
    if (pushedRowColl.indexOf(rowIdx) < 0) { 
        changedDataSource.push(dataSource[rowIdx]); // To get the changed data source. 
        type: "POST", 
        url: "SpreadsheetFeatures.aspx/Spreadsheet1_ServerCellSave", 
        data: JSON.stringify({ editedValues: JSON.stringify(changedDataSource) }), 
        contentType: "application/json; charset=utf-8", 
        dataType: "json", 
        success: function (response) { 
            // Success code here 
        error: function (err) { 
            // Error code here 
    Public Shared Function Spreadsheet1_ServerCellSave(ByVal editedValues As String) As String 
        Dim serialize As JavaScriptSerializer = New JavaScriptSerializer() 
        Dim editedData As List(Of Orders) = serialize.Deserialize(Of List(Of Orders))(editedValues) // get the updated datasource 
        SpreadsheetObj.Sheets(0).RangeSetting(0).Datasource = editedData         Return "Successfully updated" 
    End Function 
Meanwhile to scroll the selected cell after postback also can be achievable by using the “scrollToCell” method in loadComplete event. The active cellIndex is saved in the activeCell variable before postback is done in button click event and it can be demonstated in the below code example. 
var activeCell = { rowIndex: 0, colIndex: 0 }; 
function loadComplete(args) { 
            var xlFormat = this.XLFormat; 
            if (!this.isImport) { 
               this.XLScroll.scrollToCell([activeCell.rowIndex,activeCell.colIndex,activeCell.rowIndex,activeCell.colIndex])   // To scroll the last updated cell. 
Could you please check the above sample and get back to us if you need any further assistance on this? 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon