473,385 Members | 1,645 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,385 software developers and data experts.

ASP.NET - Unable to persist data between postbacks

Firstly, if this is the wrong newsgroup for my question, please direct me
elswhere and accept my apologies! It's a question about ASP.NET but also
uses VB.NET classes.

This is a little strange, but I feel I'm missing an obvious answer. Perhaps
you guru's can enlighten me?
I have webform. I also have a class, which includes the following
declaration and property:
____________

Protected _IRWKeyMilestones as IRWKeyMilestones

Public Property IRWKeyMilestones() As IRWKeyMilestones
Get
If _IRWKeyMilestones Is Nothing Then
_IRWKeyMilestones = New IRWKeyMilestones(Cascade, Me)
End If
Return _IRWKeyMilestones
End Get
Set(ByVal Value As IRWKeyMilestones)
_IRWKeyMilestones = Value
End Set
End Property
____________

The IRWKeyMilestones class is marked "<Serialisable()>" and inherits the
..net "Collection" class.

The IRWKeyMilestones collection is populated via the web form, that's not
important right now. When I refer to "IRWKeyMilestones" elsewhere in the
code, it gets it nicely from the above property as expected. And when I
change an IRWKeyMilestones item, it updates the collection nicely. So far,
so good.

I have a "Save" button on my web form, which calls a "Save" method, which
saves the collection to the database. Again, the details of that aren't
imporant right now. The point is, it works fine and the _IRWKeyMilestones
collection is persisted upon postback of the form.

Now, the problem:

I have another button, totally unrelated, elsewhere on my webform. This
button also causes a postback - to update other parts of the page. BUT
when this particular postback happens, it seems to obliterate
_IRWKeyMilestones; it sets it to Nothing. So all changes to the collection
are lost. I remind you, IRWKeyMilestones is *totally unrelated* to the
button being pressed.

Can anyone think of an obvious reason why _IRWKeyMilestones isn't being
persisted in the second instance? I thought putting "Protected" in front
of it was enough? Obviously not.

Help !

Thanks,
Owen

PS. replies cc'd via email appreciated
ow************@mantix.com

Nov 21 '05 #1
1 1768
Owen,

A webform is never persistent. Notever what you do with a non shared class
(and with that is something special see below).

You can save data using a
viewstate (that will sent it with the page, I will not advice however there
are reasons to do that)
cache(which belong to all clients which are at that time active, so you have
to set a kind of indexing)
shared class(acts the same as the cache)
session(the most easy one to use)

The normal way is to fill a session if Not IsPostBack

And to fill your classes again if it is IsPostBack

I hope this helps,

Cor
Nov 21 '05 #2

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

Similar topics

1
by: Paul Perot | last post by:
Hi All: I have a DataTable that I have defined Globally. I populate this datatable dynamically with file/folder information that I read directly from the server. I use this datatable...
1
by: Warren J. Hairston | last post by:
Can anyone point me toward a solution for persisting non-controls (i.e.: a stack) across PostBacks? TIA! - Warren
1
by: magister | last post by:
hello I am putting together a web form which builds an xml file. I have another class which is referenced in the asp.net page. The first page load creates an instance of the class. In the class...
2
by: Grey | last post by:
why cannot I persist data in three text box after postback?? I have set the ViewState to TRUE. any other setting I need to set?? Million thanks
5
by: Usenet User | last post by:
I know I can use ViewState for member fields and variables declared on Page level to persist between postbacks, for example: private const string FormModeTag = "_FormMode_"; private string...
2
by: JJ | last post by:
Hi, Not sure if the title makes sense but heres my dilemma. I have two dropdownlist controls on a webform. I want to make sure that the first dropdownlist control was clicked on and a value was...
1
by: Owen | last post by:
Firstly, if this is the wrong newsgroup for my question, please direct me elswhere and accept my apologies! It's a question about ASP.NET but also uses VB.NET classes. This is a little...
4
by: Godwin Burby | last post by:
Hi All, I'm a new comer to web development as well as asp.net. So when i fired up my first database driven page, i knew i had a problem of not having a persistent database connection across...
0
by: gobblegob | last post by:
Hello All, I am getting an error trying to update datagridview1 , what i am trying to do is search for an item (BarCode.text) and then display the results to datagridview1 but i just cannot manage...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.