metropia
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.
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.
please post code
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
ASKER
am I instantiating the variables in the wrong place in the program?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.