473,388 Members | 1,298 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,388 software developers and data experts.

textfield not recognized in gridview

Hi,

The gridview contains 7 fields (i can see them with data on screen). The
last is a
checkbox and the first six are textfields.

I did this: (just a sample code: without the
line"a=e.Row.Cells(0).Controls(0)", it works , but with that line, i get the
error:
"Specified argument was out of the range of valid values. Parameter
name:index").
The checkbox is recognized, but not the textfields.

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then
Dim a As TextBox
Dim cb As CheckBox
a=e.Row.Cells(0).Controls(0) 'error also with
Cells(1 till 5)
cb = e.Row.Cells(6).Controls(0) 'this works
end if
end sub

Maybe are these texrfield not 'textbox'? But then, what are they? How can i
know that?
Thanks

Jul 8 '06 #1
3 1189
It is nothing but innerText on "td" elements.You should always check the
lengtj of Control array. And then check each element in the control to the
type you are looking for before casting it to any control type.
"Dave" <vqsvd@sdvsdwrote in message
news:eb**************@TK2MSFTNGP05.phx.gbl...
Hi,

The gridview contains 7 fields (i can see them with data on screen). The
last is a
checkbox and the first six are textfields.

I did this: (just a sample code: without the
line"a=e.Row.Cells(0).Controls(0)", it works , but with that line, i get
the error:
"Specified argument was out of the range of valid values. Parameter
name:index").
The checkbox is recognized, but not the textfields.

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then
Dim a As TextBox
Dim cb As CheckBox
a=e.Row.Cells(0).Controls(0) 'error also with
Cells(1 till 5)
cb = e.Row.Cells(6).Controls(0) 'this works
end if
end sub

Maybe are these texrfield not 'textbox'? But then, what are they? How can
i know that?
Thanks

Jul 8 '06 #2
Hi Winista,

Two more questions and i let you alone ... promised!
(I'm trying to understand the philosophy of tbe controls in asp.net ...)
I can't find 'td' in the list of controls

1) what do i have to fill here:
dim c as ??? (i tried 'tablecell' but it failed)

2) how can i check the length of control array and each element to the type?

Thanks again
Dave

"Winista" <wi*****@gmail.comschreef in bericht
news:O9**************@TK2MSFTNGP04.phx.gbl...
It is nothing but innerText on "td" elements.You should always check the
lengtj of Control array. And then check each element in the control to the
type you are looking for before casting it to any control type.
"Dave" <vqsvd@sdvsdwrote in message
news:eb**************@TK2MSFTNGP05.phx.gbl...
>Hi,

The gridview contains 7 fields (i can see them with data on screen). The
last is a
checkbox and the first six are textfields.

I did this: (just a sample code: without the
line"a=e.Row.Cells(0).Controls(0)", it works , but with that line, i get
the error:
"Specified argument was out of the range of valid values. Parameter
name:index").
The checkbox is recognized, but not the textfields.

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then
Dim a As TextBox
Dim cb As CheckBox
a=e.Row.Cells(0).Controls(0) 'error also with
Cells(1 till 5)
cb = e.Row.Cells(6).Controls(0) 'this works
end if
end sub

Maybe are these texrfield not 'textbox'? But then, what are they? How can
i know that?
Thanks


Jul 9 '06 #3
never mind ...

"Winista" <wi*****@gmail.comschreef in bericht
news:O9**************@TK2MSFTNGP04.phx.gbl...
It is nothing but innerText on "td" elements.You should always check the
lengtj of Control array. And then check each element in the control to the
type you are looking for before casting it to any control type.
"Dave" <vqsvd@sdvsdwrote in message
news:eb**************@TK2MSFTNGP05.phx.gbl...
>Hi,

The gridview contains 7 fields (i can see them with data on screen). The
last is a
checkbox and the first six are textfields.

I did this: (just a sample code: without the
line"a=e.Row.Cells(0).Controls(0)", it works , but with that line, i get
the error:
"Specified argument was out of the range of valid values. Parameter
name:index").
The checkbox is recognized, but not the textfields.

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then
Dim a As TextBox
Dim cb As CheckBox
a=e.Row.Cells(0).Controls(0) 'error also with
Cells(1 till 5)
cb = e.Row.Cells(6).Controls(0) 'this works
end if
end sub

Maybe are these texrfield not 'textbox'? But then, what are they? How can
i know that?
Thanks


Jul 13 '06 #4

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

Similar topics

2
by: C. Armour | last post by:
Help me, I'm suffering! Situation: I have a load() function which loads a bunch of TextFields with values. There are TextListeners registered for each of these TextFields. Thus, changing the...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
1
by: Suresh | last post by:
How do I insert a char into the textfield on the keypress event of another textfield? I have two textboxes, "text1" and "text2". Important: "text1" is outside the table. "text2" is inside...
3
by: Sidney Linkers | last post by:
Hi, I'm trying to make a calculated text field in a query where the textvalue is being populated from multiple records. I already use a VBA function to loop through records and concatenate the...
10
by: dba123 | last post by:
Why am I getting this error for Budget? Error: An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code Additional information: String was not...
10
by: mercea | last post by:
hi all, i'm trying to insert the time/date a button was clicked on a gridview and it generates an error:the string was not recognized as a valid DateTime.There is an unknown word starting at index 0...
9
by: learning | last post by:
Hi! Here's my situation: I have one textfield with one 'submit' button in PAGE1.PHP. When I click on the 'submit' button I am sent to PAGE2.PHP where I have a "switch" routine that checks...
0
by: Andres Bohren | last post by:
Hi i have a GridView and have Problems to put the values into the right Datatypes. Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As...
2
jkmyoung
by: jkmyoung | last post by:
I was trying to create an applet with a TextField that would only accept an integer, and ignore any other keystrokes. Eg, if a user typed in an 'f' into the field, the TextField should ignore it, and...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.