textfield not recognized in gridview

  • Thread starter Thread starter Winista
  • Start date Start date
W

Winista

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.
 
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
 
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
 
never mind ...

Winista said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top