473,472 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I access a textbox in an asp GridView

4 New Member
I am using the following code:
Expand|Select|Wrap|Line Numbers
  1. function ZeroASN() {
  2.       if (document.getElementById("ddlheadexempcode").selectedIndex == "0")
  3.       { document.getElementById("lblError").innerHTML = "Reason code must be entered."; }
  4.       else {
  5.         var x = document.getElementById("GridDetail").rows
  6.         var z=x.length
  7.         for (i = 1; i <= z; i++) {
  8.           var y = document.getElementById("GridDetail").rows[i].cells;
  9.           y[21].document.getElementById("<%= txtRevAsn.ClientID =%>").value = "0.00"; 
  10.         }
  11.         document.getElementById("lblError").innerHTML = " ";
  12.       }
  13.     }
  14.  
The bolded statement beginning "y[21]" is the one I'm having trouble with. The one here gives me an error that txtRevASN is undefined. This is true, as it has "GridDetail" appended as a prefix plus something else.
I've tried
Expand|Select|Wrap|Line Numbers
  1. y[21].firstChild.value = "0.00"
  2.  
But this doesn't seem to work.

The following works but blows away the text box.
Expand|Select|Wrap|Line Numbers
  1. y[21].innerHTML= "0.00"
  2.  
So how do I reference the textbox?
Thank you.
Sep 10 '10 #1
5 1861
gits
5,390 Recognized Expert Moderator Expert
if your node y[21] has exactly one textbox as a childnode then you might use something like the following:

Expand|Select|Wrap|Line Numbers
  1. var childNodes = y[21].childNodes;
  2.  
  3. for (var i = 0, l = childNodes.length; i < l; i++) {
  4.     var node = childNodes[i];
  5.  
  6.     if (node.tagName != 'INPUT') {
  7.         continue;
  8.     } else {
  9.         node.value = '0.00';
  10.     }
  11. }
Sep 11 '10 #2
Ellary Kahan
4 New Member
Thank you. That worked.
Sep 13 '10 #3
Ellary Kahan
4 New Member
I keep getting an error on this statement:
var y = x.rows[i].cells;
The code does work.
Is there a correct way to do this? Or is this error caused by the fact that i is not defined until the code executes?
Sep 14 '10 #4
gits
5,390 Recognized Expert Moderator Expert
?? where does this code come from and what should it do?
Sep 15 '10 #5
Ellary Kahan
4 New Member
I found the error. I was setting z to the length of the array and in the for loop I set the subscript <= z when it should have been < z.
Thanks.
Sep 15 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: bettyann | last post by:
I am using Visual Basic 6.0. I have a TextBox control whose "Caption" I wish to access. When I look at the TextBox's structure via the "watch" window, its structure appears to look like the...
5
by: Darren Smith | last post by:
Hi There, I have a shopping cart app that displays products along with a textbox (to enter quantity) and an image button to add the item to the shopping cart. Please explain why my below...
2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
4
by: Newbee | last post by:
I'm using a table (dynamically generated at runtime) for formatting wherein I have text in the first column, and textboxes in the second column. For example, (1,1) might have the string "Last Name"...
0
by: Marc Eggenberger | last post by:
Hi all. I have a DetailView where I have one column as a template column. In the EditItemTemplate I changed the textbox to a dropdownlist which is databound. This works fine. I now added a...
1
by: Tom_Guus | last post by:
Hello, I have some problems on my textbox in MS access. I tries to solve it for the last two dats, but is still not solved. I vave a list box filled with all de customers in my database. for a...
1
by: dpark29 | last post by:
Access 2000 - If a textbox control is bound to a hyperlink field in an Access database table, the textbox appears formatted as hyperlink and when the user right-clicks the field, the Hyperlink option...
3
by: Pika | last post by:
I have a gridview with some data and I need to access to this data through javascript. Can someone help me.
1
by: ssknov | last post by:
Hi all any bdy pls tell me how to access textbox control in Form2 from Form1 thanks in advance ssk
1
by: sadaiyan | last post by:
Hello peoples, I have working in asp.net project , i am showing details in gridview and also showing gridview button control in the templatefield now i want to delete the current row when i click on...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.