Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 20th, 2007, 07:40 PM
Authorized User
Points: 139, Level: 2
Points: 139, Level: 2 Points: 139, Level: 2 Points: 139, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Spokane, WA, USA.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Persist DataSet in ViewState

This is for registering for swimming lesson sessions for the summer. The temporary (local on the client) table would hold one swimmer's registration for the summer (can't see how he could attend more than 4-5). Adds and deletes would be posted to the main database at the end of the session kind of like a shopping cart. The sessions would be like someone registering for a school semester on-line. Since only a half-dozen rows in the table would be involved it seemed possible to work with that underlying table since it was already bound to the GridView. I have never worked with a cache like a reply suggests but maybe that makes more sense.

A selection is made from another GridView and the row is added to the
underlying table of the first GridView. The ViewState of a GridView seems to work just fine when a SQL operation on the database on the server takes place and the DataSource is bound again, so a small, persisted working table bound to its own grid seems logical. However, its the working table between postbacks that collects the adds and deletes that's critical. Here's the abbreviated code which creates, saves and restores the ViewState:

Sub Page_Load
   If Not Page.IsPostBack Then
      'stmts to create dataset and table
      ViewState("aquatic") = dsAqua
   Else
      dsAqua = CType(ViewState("aquatic"), DataSet)
      dtLesson = dsAqua.Tables("lesson")
   End If
End Sub

Sub gridSessions_SelectedIndexChanged
   Dim rowSession As GridViewRow = gridSessions.SelectRow
   Dim drLesson As DataRow
   drLesson = dtLesson.NewRow()
   drLesson.Item("lessonid") = 0
   etc.
End Sub

In the page lifecycle postback events occur after load the event should act on the restored DataSet from Page_Load. But there is no schema from the DataTable returned. Maybe saving a DataSet in ViewState is not possible. But if you can keep track of a cache associated with a session and process it at the end maybe that makes more sense. I'll have to study the (Wrox etc.) books I have on it.
  #2 (permalink)  
Old May 22nd, 2007, 07:46 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I would recommend approaching this problem from a different angle. Storing a whole dataset into viewstate could give you lots of performance problems. Remember that all the viewstate is being sent back and forth between the client browser and server. Is there a reason you want to do this? Wouldn't it be better to cache the data at the server?

Perhaps if you describe the problem you are trying to solve or what you are hoping to achieve we could offer a better solution.

-Peter
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to persist Context.User across pages? musa BOOK: ASP.NET Website Programming Problem-Design-Solution 5 January 4th, 2008 12:07 AM
Persist Property Values In Controls. jahanzaib.attari ASP.NET 2.0 Basics 1 September 21st, 2007 09:19 AM
Problem with check persist KamalRaturi ASP.NET 2.0 Professional 0 September 23rd, 2006 07:12 PM
sessions wont persist bogins Beginning PHP 2 April 22nd, 2004 01:56 PM



All times are GMT -4. The time now is 08:07 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.