|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
textfield not recognized in gridviewThe 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 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 > > > 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 >> >> >> > > 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 >> >> >> > >
Dropdown List doesn't know what's in it's list
dropdown list post back not working Max Number of Web Controls Per Page??? ObjectDataSource ControlParameters Problem with ASP.NET wizard hiding / removing steps Custom Templated CompositeControl/CompositeControlDesigner Datagrid Control in VS2005 Datagrids and User Controls GridView columns don't respect width or wrap properties! How do I use multiple siteMaps? |
|||||||||||||||||||||||