Welcome,
 Guest User.

  Click to Login   


 FarPoint HOME
 clubFarPoint HOME

SUPPORT
   Forum
   Private Question
   View Your Questions

RESOURCES
   Search
   Articles
   Product Docs
   FAQ
   Training Videos
   Feature Suggestions
   Subscriptions
   User Groups
   FarPoint Blog

DOWNLOAD
   Updates
   Trials

MY ACCOUNT
   Member Benefits
   MVP Status
   RSS Feeds
   Register Product
   View Products
   View Orders
   Order Now
   My Profile
   Product Profiles

   clubFarPoint Feedback...


There are 24 registered members online.


   

Articles
<< Return to Articles
Improving Performance Using State Management
Submitted By: FarPoint Last Updated: 4/10/2006 10:42:28 AM
Level: Beginner  
Product(s): Spread for Web Forms 2  
Language(s): ASP.NET  
Description: This article introduces the idea of state management and shows how to improve performance of Spread for Web Forms using state management.  
 

To view a printable version of this article in a PDF viewer, click here for PDF.


As an ASP.NET developer, you can optimize the way your application maintains state by understanding the impact of several factors. You will want to handle state management differently depending on the amount of data, availability of the server, and the resources for implementation. You can have your application save data locally on the client (either to the View State, in a cookie, or in hidden form fields), on the server (either to the Session State or Application State) or to an SQL database (also on the server). Depending on the amount of data, some have more impact on the performance of the server and some have more on the client side.

ASP.NET pages and Web Forms components can automatically maintain state and some Web Forms components offer properties and methods that let you manage this. To provide a seamless and coherent user experience, Web-based applications must include a way of maintaining state. Take into account the various advantages and disadvantages of each solution when choosing the method of maintaining state that will optimize the performance of your application.

If you are unfamiliar with state management, first read the overview in Introducing State Management.

You can manage state while using Spread for Web Forms in different ways, including the following options:

These topics discuss the advantages and disadvantages of these options. You will want to manage data differently depending on factors such as the amount of data with which you are working. Review this information to determine the best approach for your application.

 

Back to the top.


Introducing State Management

The HTML page state is a snapshot of the state of all the page’s data and property settings. This information needs to round-trip from the server to the client to maintain a seamless and coherent user experience. The state maintains the information in the HTML page when the page is refreshed. As an ASP.NET developer, you can and should maintain the state when the page is refreshed, so that user data remains in the page. You have probably experienced pages that do not maintain state; when the page is refreshed, such as to remind you to complete part of a form, your information is lost, and you must complete the entire page again. Understandably, users prefer pages that maintain the state.

State management can be done in many ways. The method you choose can affect performance; therefore, you should understand the various ways you can manage state and choose the appropriate option for your application. You need to set up your application’s state management to optimize performance while maintaining the state.

If you are unfamiliar with state management, review the information in "Web Forms State Management" and "Introduction to Web Forms State Management" in the Microsoft Visual Studio .NET documentation.

ASP.NET pages and Web Forms components, including Spread for Web Forms, automatically maintain state. In addition, the Spread for Web Forms component offers properties and methods that let you manage the state, including:

  • FarPoint.Web.Spread.FpSpread.EnableViewState property
  • FarPoint.Web.Spread.SheetView.IsTrackingViewState property
  • FarPoint.Web.Spread.FpSpread.LoadViewState method
  • FarPoint.Web.Spread.FpSpread.SaveViewState method

The following sections discuss the advantages and disadvantages of these options. You will want to manage data differently depending on factors such as the amount of data with which you are working. You should review this information to determine the best approach for your application.

[The following information excerpts, summarizes, and adds product-specific information to the Visual Studio .NET documentation topic, "State Management Recommendations."]

If you need additional assistance with Spread for Web Forms, contact FarPoint Technologies Technical Support.

 

Back to the top.


Saving Data to the View State

View state provides client-based state management, where data is written into pages in hidden fields.

To save the data to the view state, set the IsTrackingViewState property for the active sheet to True (FpSpread1.ActiveSheetView.IsTrackingViewState = True). This is the default setting for Spread for Web Forms.

Advantages and Disadvantages

The advantages of using the view state are:

  • No server resources are required.
  • It requires less coding.
  • It requires less database access.
  • Spread manages all its data. The user changes are saved automatically to the component's data model.

The disadvantage of using view state is the impact on performance. Because the view state is stored in the page itself, storing large values can cause the page to slow down when users display it and when they post it.

Usage

The default control settings use the view state to save data. This default setting is best for small data models. If you are using larger data sets, you will probably want to use one of the other state management options.

Example

The following Visual Basic .NET sample code illustrates using the view state to save data.
 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      If (Me.IsPostBack) Then Return
 
      'connect to NWIND MS Access example with OLE DB
      Dim thisConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\NWIND.MDB")
      'open connection
      thisConnection.Open()
      'create DataSet to contain related data tables, rows,' and columns
      Dim thisDataSet As New DataSet()
 
      Dim orderAdapter As New OleDbDataAdapter("SELECT EmployeeID, LastName, FirstName, Title FROM Employees", thisConnection)
      orderAdapter.Fill(thisDataSet, "Employees")
 
      FpSpread1.ActiveSheetView.IsTrackingViewState = True
      FpSpread1.ActiveSheetView.DataSource = thisDataSet
      FpSpread1.ActiveSheetView.DataMember = "Employees"
 
      thisConnection.Close()
      thisConnection.Dispose()
End Sub
 

 

Back to the top.


Saving Data to the Session State

Session state provides server-based state management, where data is saved to separate browser sessions for each user.

To save the data to the session state, set the IsTrackingViewState property for the active sheet to True, as with saving data to the view state. Then handle the session state in the SaveOrLoadSheetState even

   

Subscribe to the RSS feed!RSS Subscribe


Come On In!
Click for Morrisville, North Carolina Forecast
 
Todays Trivia














FarPoint's Spread for Web Forms

     About Us | Contact UsComments & Suggestions | ©2008 FarPoint Technologies, Inc.