Caching (?) problem with System.Web.UI.WebControls.Table ???

G

Guest

I am using a System.Web.UI.WebControls.Table control on a screen. (Dot Net
1.1)

My problem is this: The table is programmatically reconstructed on every
postback. Each table row contains two textboxes that are intially set from
the database. None of the items in the table are 'databound'. As of now, if
the previous instance of the screen contained data in the first row boxes,
that data is carried over, even if the boxes text value is cleared in code.
(I have traced through and the boxes are being cleared in code.) Ironically,
under other circumstances I depend on this same 'effect' to get entered data,
but in this case it is completely unwanted.

What is happening here and how can data be carried over in this fashion?
 
G

Guest

You are right. In most situations, one would want this to happen. (i.e. one
would want the textboxes to be populated from the ViewState with the values
that the user entered which is considered the correct outcome)

If you simply want to discard the ViewState on those controls then set the
EnableViewState ="False" on those textboxes
 
G

Guest

Well that's the problem. I don't want to get rid of the viewstate. I need
it... part of the time. How do I control this?
 
S

Sorcerdon

How do you know if the data your seeing is the one you need?
And Why are they text boxes? can they be edited and saved? or is it
just to see the data?

If its just to see the data - Labels should be there - not text boxes.
If its to edit the data - try using the Ctrl+F5 in IE to refresh those
text boxes.

regards,

Stas K.
 
G

Guest

I'm sorry but I do not understand your response.

The controls must be textboxes because it is sometimes necessary to enter
or change data. My problem is that unwanted data seems to be carried over
into what should be a fresh display screen.
 
G

Guest

When do you decide that the data in the TextBoxes is "unwanted"?

Is it before you sent the page to the user or after you collected data from
the user?

If it is before you sent to the user then set the EnableViewState in the
codebehind to false.

If it is after you received the data from the user, then add the code (that
resets the value for the textboxes) in the Page_PreRender event processing
(because the Page_PreRender is the last event triggered before the page is
rendered and would override any thing that happened during the load viewstate
stage of the page's lifecycle)
 
S

Sorcerdon

What i mean by the reponse above,

It seems from the information you provided that you ARE prompting the
database one on page load to retrieve the data. Thus, I dont think it
is a SERVER/Development issue.
It looks like a cacheing issue. Try refreshing(F5), clearing cache,
also try using Ctrl+F5.

regards,
Stas K.
 
G

Guest

Again I am not sure I entirely understand you but I'm getting an idea.

The only thing that 'determines' whether the data is wanted in this screen
is which control triggers the postback, the submit button or a change in
dropdown selected index (a dropdown control separate from the grid.)

Are you saying I should set a variable to distinguish which control caused
the postback, check it in the prerender event, and repopulate the screen
there if necessary?
 
G

Guest

Since the decision over whether some data entered is wanted or not is based
on the control that triggers the postback then your question can be more
accurately restated as:

- How to reset the data displayed on some textboxes on the page to their
defaults if the user changed the selection on a dropdownlist that caused a
postback?

Am I correct?

One more question: Do you create the grid dynamically on your page or it is
placed declaratively and the data is then databound in the codebehind?

If the former (dynamically) then you need to separate the code that
initialize the grid complements from the code that populate the data. The
first would go in the page_init; the second would go in the page_prerender.
If the latter (declaratively) then place your code that creates the grid and
textboxes in the page_preRedner.
 
G

Guest

The table is always created dynamically. On the designer it's nothing but an
empty shell.

For the moment I have solved the problem by setting a boolean when one of
the 'filter' dropdowns is changed. This triggers a call to the table
generation proc in the prerender event.

However, thanks for the idea about separating the initialization and
population code. There is probably a great deal we can do to improve the
efficiency of this screen.

Also thanks for your prompt response.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top