473,395 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

ASP.Net State Question

Hello,
In my web application (C#) i have 2 questions related to collection state:

1- I have a Datagrid Bounded to custom Collection.. Everytime i add new item
i can see this item in the Grid but after add new item i found only the last
one even Datagrid viewstate is Enabled..
I think the problem is in my Collection which have [Serializable]
attribute.. I tried to add my collection to cache and viewstate but the
problem is still there, How could i save my collections state??

2- When i add my collection to the cache and add new item to the collection
is this apply to the cache or i have to add it back again to the cache or
view state (Is it a refrence or new instance)?? and what about viewstate is
it work in the same way as cache and what is the diffrnce between cache &
session coz as i know use the memory??

thanx
Nov 19 '05 #1
2 976
> 1- I have a Datagrid Bounded to custom Collection.. Everytime i add
new item
i can see this item in the Grid but after add new item i found only
the last
one even Datagrid viewstate is Enabled..
I think the problem is in my Collection which have [Serializable]
attribute.. I tried to add my collection to cache and viewstate but
the
problem is still there, How could i save my collections state??
I'm going to guess (since I'm having a hard time understanding the exact
problem) that you're databinding your DataGrid in Page_Load and then you're
adding a new item into your collection in a button click event. The Button
click event happens after Page_Load and that would explain why the grid doesn't
show the newly added item. In your button click event rebuild the datagrid
and it should have the newly added item.
2- When i add my collection to the cache and add new item to the
collection is this apply to the cache or i have to add it back again
to the cache or view state (Is it a refrence or new instance)?? and
what about viewstate is it work in the same way as cache and what is
the diffrnce between cache & session coz as i know use the memory??


You should not have to add data to ViewState manually on behalf if a control.
IOW, for a Label, once you set the Text property and its ViewStateEmnabled=true
it should maintain that data, not you. ViewState is so that a single page
and controls set with particular values maintain those values across postback.
Cache is a different thing. It's a server side property bag for frequently
used shared data (shared cross page and user, typically). They serve different
purposes.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Nov 19 '05 #2
your collection will be an object type which is "reference by value".
For your case, if you change a reference to to your cached object, your
object will be changed too. But as Brock said, you have to rebind your
grid after the change regardless of how you are storing the data.

Nov 19 '05 #3

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

Similar topics

1
by: Paul Tomlinson | last post by:
Question about a System.Threading.Timer object and the "state" object you pass to it... Timer stateTimer = new Timer( = new TimerCallback( OnTimer ), o, 1000, 1000); I have an array of timer...
0
by: Jacob Jozwiak | last post by:
Hi, I hope that someone has come across this problem in their travels, because it is causing me quite a bit of grief. I apologise for the length of this question. We are running a web farm...
1
by: John Grandy | last post by:
Could someone point me in the direction of good discussions on scalable state management solutions? Specifically, pros and cons of following strategies: Strategy 1 : temporary business-objects...
10
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
4
by: Shawnk | last post by:
This post is intended to verify that true value semantics DO NOT EXIST for the Enum class (relative to boolean operations). If this is true then (thus and therefore) you can not design state...
70
by: Anson.Stuggart | last post by:
I'm designing a debounce filter using Finite State Machine. The FSM behavior is it follows the inital input bit and thinks that's real output until it receives 3 consecutive same bits and it...
11
by: tuom.larsen | last post by:
Dear list, I'm writing very simple state machine library, like this: _state = None def set_state(state): global _state _state = state
2
by: tat | last post by:
Hi all, Sorry if this question is off-topic. I would like have your suggestion . I need to write one application which control a machine via serial port. There are 5 states in the following...
4
by: laktofil | last post by:
This may seem like an abstract question on behavioral inheritance. Anyway, I'm building a hierarchical state machine in C++ (with gcc for target platform Gentoo Linux). More precisely, I'm using this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.