|
 |
aspdotnet_website_programming thread: why didn't this work
Message #1 by "Greg Partin" <GPartin@c...> on Fri, 11 Oct 2002 08:28:46 -0700
|
|
Hi all,
I'm doing an update on a datagrid and using the following code:
Public Sub DataGrid_Update(ByVal source As Object, ByVal e As
DataGridCommandEventArgs)
Dim txtSubject As TextBox = e.Item.Cells(3).Controls(0)
...my code breaks here with a "cast not valid" error. I know that the
control in cell 3 is a textbox and the following code works:
Public Sub DataGrid_Update(ByVal source As Object, ByVal e As
DataGridCommandEventArgs)
Dim txtSubject As TextBox
txtSubject = CType(e.Item.Cells(3).FindControl("txtSubject"), TextBox)
What is the difference? Is there a good way to see what is at
e.Item.Cells(3).Controls(0) for debugging purposes since it seems that
the control is not really there? I am using EditItemTemplates, does
that factor into this mess?
thanks for you input,
Greg
Greg Partin
Software Engineer
CompassLearning, Inc.
2400 N. Commerce Pkwy.
Suite #404
Weston, FL 33326
Message #2 by "Sunit" <sjoshi@i...> on Fri, 11 Oct 2002 19:16:16
|
|
Since e.Item.Cells(3).Controls(0) returns an Object and you have to down-cast to a TextBox.
regards
Sunit
> Hi all,
I'm doing an update on a datagrid and using the following code:
Public Sub DataGrid_Update(ByVal source As Object, ByVal e As
DataGridCommandEventArgs)
Dim txtSubject As TextBox = e.Item.Cells(3).Controls(0)
...my code breaks here with a "cast not valid" error. I know that the
control in cell 3 is a textbox and the following code works:
Public Sub DataGrid_Update(ByVal source As Object, ByVal e As
DataGridCommandEventArgs)
Dim txtSubject As TextBox
txtSubject = CType(e.Item.Cells(3).FindControl("txtSubject"), TextBox)
What is the difference? Is there a good way to see what is at
e.Item.Cells(3).Controls(0) for debugging purposes since it seems that
the control is not really there? I am using EditItemTemplates, does
that factor into this mess?
thanks for you input,
Greg
Greg Partin
Software Engineer
CompassLearning, Inc.
2400 N. Commerce Pkwy.
Suite #404
Weston, FL 33326
|
|
 |