textfield not recognized in gridview

Discussion in 'ASP .Net Web Controls' started by Winista, Jul 8, 2006.

  1. Winista

    Winista Guest

    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:...
    > 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
    >
    >
    >
    Winista, Jul 8, 2006
    #1
    1. Advertising

  2. Winista

    Dave Guest

    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
    Dave, Jul 8, 2006
    #2
    1. Advertising

  3. Winista

    Dave Guest

    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" <> schreef in bericht
    news:...
    > 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:...
    >> 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
    >>
    >>
    >>

    >
    >
    Dave, Jul 9, 2006
    #3
  4. Winista

    Dave Guest

    never mind ...

    "Winista" <> schreef in bericht
    news:...
    > 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:...
    >> 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
    >>
    >>
    >>

    >
    >
    Dave, Jul 13, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S. Justin Gengo
    Replies:
    0
    Views:
    496
    S. Justin Gengo
    Aug 26, 2003
  2. Mickey Segal
    Replies:
    0
    Views:
    618
    Mickey Segal
    Sep 15, 2004
  3. Winista

    textfield not recognized in gridview

    Winista, Jul 8, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    3,186
  4. JohnE

    gridview not recognized

    JohnE, Jun 1, 2010, in forum: ASP .Net
    Replies:
    0
    Views:
    447
    JohnE
    Jun 1, 2010
  5. Sebastian Terodde

    Gridview Textfield

    Sebastian Terodde, Jul 4, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    189
Loading...

Share This Page