Link to home
Start Free TrialLog in
Avatar of metropia
metropiaFlag for United States of America

asked on

how to not lose variables values using calculate and submit button

I have an asp.net page/ form with two button.

the first button is enabled and it is used to calculated some fields based on other fields inputs.

after the calculation is completed, then the second button becomes enabled, and allows the user to submit the user entered values, and the calculated values into a database table.

my problem is that when i click the second button, the variables and their values are lost, because i instantiate them at the very beginning of the page.

how can i do so that the values are not lost when the second button is clicked and the field values are already there?

I can post my code if my question is not clear


Thanks you.
Avatar of yawkey13
yawkey13
Flag of United States of America image

please post code
Avatar of metropia

ASKER

the first button is btnCalculatedFields_Click

second button btnSubmit_Click

when i click on it, all the variables are set back to their original state.

thanks for your help.
DataEntry.aspx.cs
SOLUTION
Avatar of yawkey13
yawkey13
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, I did that but still I lose all the values.

I click the calculate fields button, I get all the values, calculated and from the form.

When I click the submit button, and go into the insert statement, the date is null,
and all the calculated fields are set to 0.
am I instantiating the variables in the wrong place in the program?
ASKER CERTIFIED SOLUTION
Avatar of srikanthreddyn143
srikanthreddyn143

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
is it a good option to use session variables?
I added a few and they seem to work, but I am unsure as to whether is recommendable or not to use them.

Thank you.
You are using some server memory by using session variables. You should use them when you have no other of way of handling.