[SOLVED] DevExpress ASPSpreadsheet Control do not works correctly



I am trying DevExpress  ASPSpreadsheet Control with VISEJ 2.05 but it do not eorks well. AddRow, DeleteRow and any layout changes after control being loaded do not works.

What may be the problem?

Thank you!


Public Class CDevexSpreadSheet

Inherits Wisej.Web.Ext.AspNetControl.AspNetWrapper(Of DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet)
Dim WithEvents OWrapedControl As DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet = Nothing

Public Sub New()
Me.Dock = Wisej.Web.DockStyle.Fill
AddHandler DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet.CellValueChanged, AddressOf   CStaticEventHandlers.EventHandelr_CDevexSpreadSheet_CellValueChanged
End Sub

Private Sub DEVEXGrid_LoadComplete(sender As Object, e As EventArgs) Handles Me.LoadComplete
Dim OMyWebComponentWRAPED As DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet = CType(Me.WrappedControl,         DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet)
RaiseEvent CEventComponentExposer(OMyWebComponentWRAPED)
End Sub

Public Event CEventComponentExposer(InOMyWebComponentWRAPED As DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet)

End Class

  • You must to post comments
Best Answer

I just tried, the AspNetWrapper control in Wisej works very well. The problem is that ASP.NET doesn’t work the same way as Wisej and your code cannot update the DevExpress ASPxSpreadsheet control because you are saving a reference to the instance that doesn’t exist anymore. Wisej makes it too easy… 🙂

The same approach used in your sample doesn’t work in any framework, including ASP.NET itself. ASP.NET controls do not exist past the page cycle.  VB.NET (or C#) code can interact with an ASP.NET control only when the page is initialized or loaded (which is during a page request from the browser). After the response (which is a large concatenated HTML string) is sent back, the ASP.NET controls are discarded. They will be all recreated from scratch at the next request (or postback for a form).

If the clicks in your sample were coming from an ASP.NET page, it would work because the click issues a full page request and the entire ASPxSpreadsheet is recreated. Wisej is a Single Page Application (SPA) system completely based on asynchronous (ajax) communications. Very similar to a single ASP.NET update panel. If you tried to update the ASPxSpreadsheet in an ajax request in ASP.NET it would not work. See https://www.devexpress.com/Support/Center/Question/Details/T399187/how-to-refresh-aspxspreadsheet-without-refreshing-the-whole-page.

This is why the AspNetWrapper shows the WrappedControl property which is the reference to the live instance of the ASP.NET control. If you save that reference in your code you are referring to a “dead” instance past the Page_Init, Page_Load (etc, see reference doc).

Basically, ajax code can use ASP.NET control only during a page request.

You can do this:

Add a method to the wrapper

 Public Sub Test()
    doSomething = True
 End Sub
 Dim doSomething As Boolean

 Private Sub CDevexSpreadSheet_Init(sender As Object, e As EventArgs) Handles Me.Init
    If (doSomething) Then
      Me.WrappedControl.Document.Worksheets(0).Rows(1).FillColor = Drawing.Color.Red
    End If

 End Sub

Now you can call Test() at anything from an ajax event coming from a Wisej control. The method Test will call Update() which will reload the spreadsheet.

To prevent the full reloading, see the explanation at the DevExpress support forum: https://www.devexpress.com/Support/Center/Question/Details/T399187/how-to-refresh-aspxspreadsheet-without-refreshing-the-whole-page

You can assign the ClientInstanceName in Page_Init and you will find it on the client side.

     Me.WrappedControl.ClientInstanceName = "Spreadsheet1"

Then in Test() instead of Update(), call this:


It will update the ASPxSpreadsheet using a postback as advised by DevExpress.

You may get other problems after this in your sample because the way it’s written it recreates the sheet on every load, which conflicts with the typical ASP.NET postback model. In the AspNetWrapper we also expose IsCallback and IsPostback. This way you can check if the load event is fired because of an ASP.NET postback.

In other words, anything you want to do to the ASPxSpreadsheet object can only be done while inside Page_Init or Page_Load or the other page initialization events.





  • Raciel Porto
    Hey Luca, I have a question that still has me confused. When i wrapped an ASP signature control in VWG (it was done through a wrapper wizard they had), i initialized everything for that control and they i could just from my code query/modify any property without having to wait for another callback or reload the control (unless i don’t understand it correctly). When i try to follow your approach in this example now that i am converting my code to wisej, the new “load” of the wrappedcontrol is coming with the default initial properties, nothing (in my case) for whatever the user signed in the control itself (which actually looks like it was signed on the screen, by the way). What am I doing wrong here (i know i am missing something)? Or is it that the VWG approach for wrapping asp controls is totally different that wisej ? Thanks
  • Luca (ITG)
    ASP.NET controls (and pages) do not exist outside of the page life cycle (https://blogs.msdn.microsoft.com/aspnetue/2010/01/14/asp-net-page-life-cycle-diagram/). The VWG wizard maybe was caching the values into the session and then reapply them at PageInit or PageLoad. Our wrapper is very lean and works with extremely complex ASP.NET controls like the stimulsoft report designer. Simply storing a property and reapplying it may work for some controls but I found that it creates a lot of problems. For example, we had a VWG project using the DevExpress ASP.NET file browser crashing the server because VWG was trying to put the entire file tree into the response header. With the Wisej ASP.NET control wrapper you can store properties at any time and then update the control in Init, or Load or PreInit, etc. You can force the update by calling Update(). There is no other way with ASP.NET because, as I said, the instance is simply recreated by .ASP.NET every time – even when using UpdatePanels.
  • You must to post comments

Thank you!

It all works!

But I am still not able to get CELL CHANGE event. Would you help with this please?


  • Frank (ITG)
    Can you please send us what you have done so far so we can check how to attach to the cell change event ? Please send to frankATiceteagroup.com
  • You must to post comments

Thank you!

I will study your solution.


Do you have a working sample wrapping for ASPxSpreadsheet wiht most functions of ASPxSpreadsheet working. I will be happy to see it.

Thank you again!

  • You must to post comments

I hope the sample project will do for the problem demonstration purpose.

After  initialising the spreadsheet is like dead. Nor row add, hiding, painting and so on. Only cell value setting works.

Also I need active cell change event.

Thank you!!!


  • You must to post comments

Please attach a small test case.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.