AllExperts > Active Server Pages Programming (ASP) 
Search      
Active Server Pages Programming (ASP)
Volunteer
Answers to thousands of questions
 Home · More Active Server Pages Programming (ASP) Questions · Answer Library  · Encyclopedia ·
More Active Server Pages Programming (ASP) Answers
Question Library

Ask a question about Active Server Pages Programming (ASP)
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About robert mamayev
Expertise
Main focus is classic ASP, Oracle 9i and 10g and MySQL databases

Experience
I am an expert with classicASP. I can answer any questions you might have about the ASP language, HTML, website design and development. I am not an expert in ASP.NET yet, so please don't ask me any questions specific to ASP.NET. Also, be sure to visit my IdeaJets website.

Publications
Article List

Education/Credentials
BS in Computer Science, Queens College, NYC

Awards and Honors
Oracle Database Certified Professional (9i databases)

Past/Present Clients
Pfizer, MasterCard

 
   

You are here:  Experts > Computing/Technology > Business Software > Active Server Pages Programming (ASP) > Data in memory

Active Server Pages Programming (ASP) - Data in memory


Expert: robert mamayev - 10/13/2009

Question
QUESTION: Hello,

In ASP if you have a grid on a page where the user will be adding data (rows). How can all the rows of data be kept in memory until the user saves them to the database?

Thanks in advance,

Richard

ANSWER: Richard, the best way is to create an array of hidden variables and store the grid value in them. If you have a recordset, then create a variable, initialize it to 0 and in the recodset loop append index variable to hidden variable. You will end up with something like this:
<input type="hidden" id=test0 value="123">
<input type="hidden" id=test1 value="234">...

Then on submit use javascript to process these variabes.

Regards,
Robert

---------- FOLLOW-UP ----------

QUESTION: Hi Robert,

In my case I don't know in advance how many rows the user is going to add, I don't know how many "testN" hidden fields will be needed. Is there a way to do it? Your help will be greatly appreciated.

Sincerely,

Richard

Answer
Richard, you can do the following:

create a hidden variable counter. Initialize it to 0. When the user inserts data, do the following:

On submit (whenever user inserts data),

1. in ASP generate hidden variable with id = hidden_counter value="user_data"

2. in javascript, increment value of counter (counter++)

This should work and provide you with dynamic solution.  

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.