473,748 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2538
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
4502
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 text file in a list box so the user can see the total car fleet, my problem is that I want everything to line up. So far what I'm getting is something like: R296RKV Ford Mondeo Large On Hire TUVWXYZ ...
7
1533
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 the total of each row. The form initially is loaded with zeros so Total would be zero. If a user modifies a value, I want it immediately added in the coressponding box at the end of each column. Second question.. I want to validate every input...
4
12846
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 achieved.
2
1805
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 edit mode and four text boxes appear, one is for the start date, another for an end date and the other two are for other data, the user fills in the fields and saves the data, all is great at this point, an entry is added ok. However the problem I...
0
3814
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 using a web service to load the dataset and update the data. Here is what I am doing. I have an existing record in the database. I created a datagrid bound to the dataset.
10
9573
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, not ID's, so I have to convert the ID's from various lookup tables. The combo boxes work fine except for subcategory, which is dependent on category. Depending on category, the drop-down box for subcategory will display different items. (for...
5
1600
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 checkboxes (unbound?) which user can tick. Is there an example of such a scenario somewhere that I can have a look at? Thanks
1
1222
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 the grid being displayed in the text boxes. I have a code for the text boxes that look like this, but I am getting an "out of index" error: txtInstitution.Visible=true; txtInstitution.Text = ((TextBox)e.Item.Cells.Controls).Text;
0
2435
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 a data view (which in turn is loaded from a manually setup DataTable for testing purposes). One of the columns in the grid is a checkbox that's tied to an event handler that'll change the .Visible property of a column with a text box. That text...
0
8822
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9359
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9236
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8235
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6792
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6072
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.