473,699 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about viewstate

I have a grid that I databind with a strongly typed
dataset which contains thousands of records retrieved
from a database. After the dataset is retrieved from the
database, I place it in viewstate. I need to do this
because of the following:

A user is allowed to check "x" amount of rows on the grid
and submit those records (which causes a postback) to the
database for updating. At this point, I grab the dataset
from viewstate and simply process those records from the
appropriate event. The records in the dataset are
processed depending on which rows were checked on the
grid. The syncing of rows in the grid to the dataset is
exactly the same which is expected.

However, based on the dataset being large, this can
reduce performance because of the dataset which was
placed in viewstate. If I don't place the dataset in
viewstate and grab the records from the database again
performing the databind, the rows that the user checked
will be lost. Even if I somehow save the rows that were
checked via viewstate in between postbacks and apply that
to the dataset after the databind, the application runs
the risk of the rows being out of sync on the datagrid to
the dataset, because some other user could have processed
those rows. If custom paging is implemented on the grid,
I suppose this would reduce the work load on the data in
viewstate which defintely would be acceptable. If not
using custom paging, this scenario would still exist.

Can somone please shed some light on whether or not my
thinking is correct?
How would one deal with this scenario?
Nov 18 '05 #1
2 1123
I doubt that you can very well display thousands of records in a single HTML
document. Perhaps you should only fetch 100 at a time.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Bill Yeager" <an*******@disc ussions.microso ft.com> wrote in message
news:42******** *************** *****@phx.gbl.. .
I have a grid that I databind with a strongly typed
dataset which contains thousands of records retrieved
from a database. After the dataset is retrieved from the
database, I place it in viewstate. I need to do this
because of the following:

A user is allowed to check "x" amount of rows on the grid
and submit those records (which causes a postback) to the
database for updating. At this point, I grab the dataset
from viewstate and simply process those records from the
appropriate event. The records in the dataset are
processed depending on which rows were checked on the
grid. The syncing of rows in the grid to the dataset is
exactly the same which is expected.

However, based on the dataset being large, this can
reduce performance because of the dataset which was
placed in viewstate. If I don't place the dataset in
viewstate and grab the records from the database again
performing the databind, the rows that the user checked
will be lost. Even if I somehow save the rows that were
checked via viewstate in between postbacks and apply that
to the dataset after the databind, the application runs
the risk of the rows being out of sync on the datagrid to
the dataset, because some other user could have processed
those rows. If custom paging is implemented on the grid,
I suppose this would reduce the work load on the data in
viewstate which defintely would be acceptable. If not
using custom paging, this scenario would still exist.

Can somone please shed some light on whether or not my
thinking is correct?
How would one deal with this scenario?

Nov 18 '05 #2
What about trying to use SessionState instead? Granted, this uses more
server memory, but it definitely will cut down on the amount of data that
you have to pass back and forth to the client.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"Bill Yeager" <an*******@disc ussions.microso ft.com> wrote in message
news:42******** *************** *****@phx.gbl.. .
I have a grid that I databind with a strongly typed
dataset which contains thousands of records retrieved
from a database. After the dataset is retrieved from the
database, I place it in viewstate. I need to do this
because of the following:

A user is allowed to check "x" amount of rows on the grid
and submit those records (which causes a postback) to the
database for updating. At this point, I grab the dataset
from viewstate and simply process those records from the
appropriate event. The records in the dataset are
processed depending on which rows were checked on the
grid. The syncing of rows in the grid to the dataset is
exactly the same which is expected.

However, based on the dataset being large, this can
reduce performance because of the dataset which was
placed in viewstate. If I don't place the dataset in
viewstate and grab the records from the database again
performing the databind, the rows that the user checked
will be lost. Even if I somehow save the rows that were
checked via viewstate in between postbacks and apply that
to the dataset after the databind, the application runs
the risk of the rows being out of sync on the datagrid to
the dataset, because some other user could have processed
those rows. If custom paging is implemented on the grid,
I suppose this would reduce the work load on the data in
viewstate which defintely would be acceptable. If not
using custom paging, this scenario would still exist.

Can somone please shed some light on whether or not my
thinking is correct?
How would one deal with this scenario?

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1649
by: Mike P | last post by:
I have the following code in my Page_Load event to populate a listbox from a database : if (!(Page.IsPostBack)) { SqlConnection objConnection = new SqlConnection(ConfigurationSettings.AppSettings ); string strTelcoNumber = "SELECT DISTINCT OSValue FROM CallTypeSwitch ORDER BY OSValue";
5
1645
by: Craig Buchanan | last post by:
I'm using a viewstate key/value to store a serialized instance of a class. If I redirect to another aspx page, the viewstate is lost. Is this the intended behavior of the viewstate? Is there a work around? Cookies, I suppose. Thanks, Craig Buchanan
2
1153
by: Gandalf | last post by:
Say I have persisted a DataSet in the ViewState of a page, and that when the page is posted back I make several references to that dataset like so: DataSet MyDataSet = (DataSet)ViewState; //C# Does this have to deserialize the dataset every time it is referenced... or is it only done once when the page is posted back? I'm just wondering if I should assign the DataSet to a local variable in the PageLoad method or if it's OK to...
1
1208
by: Raed Sawalha | last post by:
Hi I have created a usercontrol in which I save a value in viewstate like this: ViewState=value; If I use the same key (ViewState=value;) in my master page, does the framework recognize where the value comes from ? Or have I to set ViewState=value; and ViewState=value; ? Regards
6
1934
by: Chris | last post by:
I've created two textboxes and one button on my web form. I then set the EnableViewState property of Textbox1 to False. Textbox2 is set to True. The button has no code in it - It simply has an auto post back which reloads the page. I run the web application and type "test 1" into Textbox1 and "test 2" into Textbox2. I click the button and the page reloads. Textbox1 has the value of "test 1". Textbox2 has the value of "test 2". Am...
6
2742
by: John | last post by:
Hi all, I am using dynamic user controls within my web app and these controls are loaded into placeholders via the LoadControl method. My problem is this: I have usercontrolA loaded into a placholder and the user clicks on a specific control outside of the usercontrol and some Javascript is run where a hidden variable is changed to reflect another usercontrol (usercontrolB).
6
1840
by: Bryan | last post by:
I've got an ASP.NET application running that has a non-visual user interface (it's a voice app using VXML.) The voice client understands cookies and when it requests and aspx page, what actually gets returned is VXML code. I'd like to be able to postback data to my page. I can send data with no problem (using VXML submit with method post) but at the server IsPostBack is always false. How does the server determine if it is a PostBack? I...
5
1774
by: Mark Olbert | last post by:
I have a composite control (under ASPNET2; derived from CompositeControl) which contains a label. The contents of the label are set when the control is created to a user-supplied value. What's confusing me is that on postback the contents of the label are not being restored from ViewState. I thought that happened automagically...but I guess not. I'm obviously missing something really simple. How do I get the label to set its text from...
2
265
by: Carly | last post by:
Hi, I am now not sure I understand what ViewState does. Having EnableViewState=true or false on a WEB form and/or different server controls does not seem to make any difference. I am just playing around with VS 2005 and no matter the value of EnableViewState all the controls maintain their value. Can anybody explain or point me to a clear article about this subject. Much appreciated,
5
5894
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to store a DataTable in any other way outside of our servers. In doing so, we leave ourselves open to large memory requirements. Furthermore, most web pages do not really support multiple changes per transaction. In other words, when the user submits...
0
8689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8885
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.