473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Loop through all text boxes a column in a grid

I have a GridView which dynamically creates text boxes. It could be
between 1 and 100 textboxes depending on how many records there are in
the database.

I need to loop through all the text boxes and to calculate a sum of all
of them which I put into a label in the grid.

I give the text box the name "txtAmount" but the GridView renames each
text box so I never really know the final name.

I'm very grateful for help!

Regards,

Staeri

Feb 16 '06 #1
2 2519
You don't have to reference the text boxes by name; you could simply
reference them by form element. Every form has an array, which keeps
track of its form elements, and references them starting at 0. For
example, if you have a text box, a radio button, and a pull-down menu,
in that order, you could reference them as formelement[0],
formelement[1], and formelement[2], respectively. Just make sure you
get the references right; if you don't, and you (say) try to parse a
radio button thinking it is a text box, you will get errors.

You would keep track of the size of the array with the length feature.

View the source code on the following page; it shows an example of
referencing the form elements, but the form itself is static (so the
length feature doesn't have to be used):

http://www.akiti.ca/LinLeastSqPoly4.html

Feb 16 '06 #2
mh*****@netzero.net wrote:
You don't have to reference the text boxes by name; you could simply
reference them by form element. Every form has an array, which keeps
track of its form elements, and references them starting at 0.


The `elements' property refers to an HTMLCollection object, not to an
Array object.
PointedEars
Feb 17 '06 #3

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

Similar topics

6
by: Roy Riddex | last post by:
I have a text file which holds data for 30 cars in the following way: CarRegistration CarType CarClass Available I'm trying to display the full contents of this...
7
by: Marios Koumides | last post by:
I post the same question few days ago but there was a confusion in the answers. Anywayz I am posting again. I have a form with 96 textboxes (8 rows x 12 columns) Now I want in the last row to have...
4
by: godber | last post by:
I need to populate text boxes for instance with employee information using their unique employee works number selected from a combo box. Can anyone help, I am told thru visual basic this can be...
2
by: Gary | last post by:
Hello All, I have an editable data grid in my web form, this grid allows the user to add new records, edit existing records and also delete them. When a user adds a record the grid goes in to...
0
by: Lance Geeck | last post by:
Hi, I am trying to learn the VB.NET approach and am having problems with updating the database. What I have is a simple windows form using text boxes for entering name, address and phone. It is...
10
by: lorirobn | last post by:
Hi, I have a form with several combo boxes, continuous form format, with record source a query off an Item Table. The fields are Category, Subcategory, and Color. I am displaying descriptions,...
5
by: John | last post by:
Hi I have a bound gridview. I need to allow users to select multiple rows and then press the process button to process multiple selected rows. For this I want to use additional column of...
1
by: Antonio | last post by:
Can somebody help me? When a user clicks on the Edit button in a data grid, the record stays in the data grid but text boxes outside the grid are displayed and I would like to have the data from...
0
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.