G
Greg
I have a datagrid control with a template column. I am trying to get
the text out of the textbox control.
The FindControl method finds the control but it always brings back ""
as the text value regardless of what I enter in the text box?
Dim strDay As String = CType(e.Item.FindControl("txtDay"),
TextBox).Text
--------------------------------------------------------------------------
Here is the full code of the event
---------------------------------------------------------------------------
Public Sub dgrdPlans_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgrdPlans.UpdateCommand
Static varPlanID As Integer
Dim varRowIndex As Integer
varRowIndex = e.Item.ItemIndex
varPlanID = CInt(dgrdPlans.Items(varRowIndex).Cells(3).Text)
Dim strDay As String = CType(e.Item.FindControl("txtDay"),
TextBox).Text
Dim txtAchieveMonth As TextBox =
CType(e.Item.FindControl("txtMonth"), TextBox)
Dim strMonth As String
strMonth = txtAchieveMonth.Text
Dim txtAchieveYear As TextBox =
CType(e.Item.FindControl("txtYear"), TextBox)
Dim strYear As String
strYear = txtAchieveYear.Text
Dim dteAchieveDate As Date
'Check that there is a valid date
If IsDate(CDate(strDay & "/" & strMonth & "/" & strYear)) Then
dteAchieveDate = (CDate(strDay & "/" & strMonth & "/" &
strYear))
End If
Try
InsertActivity(varPlanID, dteAchieveDate)
Catch sqlEx As SqlException
Response.Write(sqlEx.ToString)
Catch ex As Exception
Response.Write(ex.ToString)
Finally
dgrdPlans.EditItemIndex = -1
'LoadDataGrid1()
End Try
End Sub
Thanks
Greg
the text out of the textbox control.
The FindControl method finds the control but it always brings back ""
as the text value regardless of what I enter in the text box?
Dim strDay As String = CType(e.Item.FindControl("txtDay"),
TextBox).Text
--------------------------------------------------------------------------
Here is the full code of the event
---------------------------------------------------------------------------
Public Sub dgrdPlans_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgrdPlans.UpdateCommand
Static varPlanID As Integer
Dim varRowIndex As Integer
varRowIndex = e.Item.ItemIndex
varPlanID = CInt(dgrdPlans.Items(varRowIndex).Cells(3).Text)
Dim strDay As String = CType(e.Item.FindControl("txtDay"),
TextBox).Text
Dim txtAchieveMonth As TextBox =
CType(e.Item.FindControl("txtMonth"), TextBox)
Dim strMonth As String
strMonth = txtAchieveMonth.Text
Dim txtAchieveYear As TextBox =
CType(e.Item.FindControl("txtYear"), TextBox)
Dim strYear As String
strYear = txtAchieveYear.Text
Dim dteAchieveDate As Date
'Check that there is a valid date
If IsDate(CDate(strDay & "/" & strMonth & "/" & strYear)) Then
dteAchieveDate = (CDate(strDay & "/" & strMonth & "/" &
strYear))
End If
Try
InsertActivity(varPlanID, dteAchieveDate)
Catch sqlEx As SqlException
Response.Write(sqlEx.ToString)
Catch ex As Exception
Response.Write(ex.ToString)
Finally
dgrdPlans.EditItemIndex = -1
'LoadDataGrid1()
End Try
End Sub
Thanks
Greg