473,508 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

View State Issues

I am writing a complex data editor, and I am building a table with
other controls in it on the fly. ( I know, not for the faint of heart.
My other options are a quadruply nested data repeater, which is ugly
in its own right)
When the form first loads up, I populate a drop down list, set the
selected item to the first item, return my data for the selected item
in the drop down list, then build my table.
I am creating a few hidden controls in each row of the table to keep
track of some information.
I've been googling for days, and all of the viewstate articles I come
across usually deal with information not being persisted in
dynamically loaded controls.
However, my problem is just the opposite. Even though I set the value
of the hidden field in code everytime I rebuild the table, it
maintains the value that it had when the page first loaded up. I tried
setting the EnableViewState property for the hidden field to false
both before and after I add it to the controls collection to no avail.
The other interesting thing to note here is that my dynamically loaded
textboxes work fine, because when I load a different set of data, the
ID of the textbox changes, whereas the ID of the hidden fields stays
pretty much constant.
How can I prevent the value of my hidden fields from being overwritten
by the view state when I reload them?
Thanks!
Jun 27 '08 #1
4 927
Part of my problem here is a "chicken and egg" problem that I don't
know how to get around. If the drop down list has changed, then I need
to clear out and totally redo with a different set of data. If the
postback was caused by another reason (like the submit button which
will cause me to save the changed data to the database) then I need to
simply reload, preserving the values so I can read them in the button
process event.
Does that make sense?
Jun 27 '08 #2
On Jun 5, 12:04*pm, Jeremy <jeremy.mitch...@gmail.comwrote:
Part of my problem here is a "chicken and egg" problem that I don't
know how to get around. If the drop down list has changed, then I need
to clear out and totally redo with a different set of data. If the
postback was caused by another reason (like the submit button which
will cause me to save the changed data to the database) then I need to
simply reload, preserving the values so I can read them in the button
process event.
Does that make sense?

I'd have to see the code to really understand whats going on but my
intial reaction is that you need to capture the values you need on
postback (in the button event) and then put them back into the fields
on the pageload or prerender event.

If you can provide a simplied version of the code you're running I'd
be happy to take a look and give some suggestions.
Jun 27 '08 #3
I've been doing alot of reading on ViewState, and I think the problem
is that I am setting the values too late in the cycle, since I am
dynamically loading all of my controls in the Page Load event.
One of the articles I read suggested loading the controls in the Init
event, but my problem is that I have to load data in response to the
selected value of the drop down list. In doing a quick experiment, the
SelectedIndex property of the drop down list in the Init event is
always -1, so I can't populate my data correctly.
The only thing I can think to do is redirect to myself when the drop
down list is changed passing in the data that I need through a query
string parameter, and that just seems horrible to me.

Jun 27 '08 #4
On Jun 6, 9:21*am, Jeremy <jeremy.mitch...@gmail.comwrote:
I've been doing alot of reading on ViewState, and I think the problem
is that I am setting the values too late in the cycle, since I am
dynamically loading all of my controls in the Page Load event.
One of the articles I read suggested loading the controls in the Init
event, but my problem is that I have to load data in response to the
selected value of the drop down list. In doing a quick experiment, the
SelectedIndex property of the drop down list in the Init event is
always -1, so I can't populate my data correctly.
The only thing I can think to do is redirect to myself when the drop
down list is changed passing in the data that I need through a query
string parameter, and that just seems horrible to me.

are you're binding all your data in the page load event?

instead of redirecting your page to itself (i imagine you're
suggesting that to reload the data you need by firing the pageload
event) move that specific code to it's own function (name it
'BindData' or something) and then call that function wherever you need
it - in the pageload and in the selectedindexchanged event of the
dropdownlist.

im just taking shots in the dark here - if you're still stumped dont
be afraid to post a code example for people to look at. Just be
careful of sharing data-sensitive material though =) dont wanna upset
"the man"
Jun 27 '08 #5

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

Similar topics

12
2613
by: Neil | last post by:
I previously posted re. this, but thought I'd try again with a summary of facts. I have an Access 2000 MDB with a SQL Server 7 back end. There is a view that is linked to the database via ODBC...
3
2111
by: Philip Tripp | last post by:
I've read numerous sources stating that view state can be disabled per control, and per page, but can't seem to keep web form controls from remembering their state on a postback. I'm using VS.Net...
104
10757
by: Beowulf | last post by:
I have the view below and if I use vwRouteReference as the rowsource for a combo box in an MS Access form or run "SELECT * FROM vwRouteReference" in SQL Query Analyzer, the rows don't come through...
0
1236
by: Bob Rock | last post by:
Hello, I remember time back having read an article about issues (I believe related to state view / postbacks) when doing url redirection via HttpModules. Since I'm writing one now I would be...
12
4687
by: brwalias | last post by:
Hi, using .net 2 sql server 2005 Here is my situation: I'm passing a variable in the url from a selection on Page A and need to display the results on the Results page be based on that...
0
7233
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
7342
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,...
1
7067
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
4729
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...
0
3215
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...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
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 ...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
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...

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.