Home All Groups Group Topic Archive Search About

textfield not recognized in gridview

Author
8 Jul 2006 8:33 PM
Dave
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

Author
8 Jul 2006 11:03 AM
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.


Show quoteHide quote
"Dave" <vqsvd@sdvsd> wrote in message
news:eb3D32soGHA.3452@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
>
>
>
Author
9 Jul 2006 8:46 AM
Dave
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



Show quoteHide quote
"Winista" <wini***@gmail.com> schreef in bericht
news:O93r7KuoGHA.3900@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@sdvsd> wrote in message
> news:eb3D32soGHA.3452@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
>>
>>
>>
>
>
Author
13 Jul 2006 1:56 PM
Dave
never mind ...

Show quoteHide quote
"Winista" <wini***@gmail.com> schreef in bericht
news:O93r7KuoGHA.3900@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@sdvsd> wrote in message
> news:eb3D32soGHA.3452@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
>>
>>
>>
>
>