D
David C
I have a FormView that is in an aspx page with a Master Page. I am trying
to show or hide 2 controls based on a condition. Below is part of the
DataBound event code that I am having a problem with.
Protected Sub fvActivityHistory_DataBound(ByVal sender As Object, ByVal
e As System.EventArgs) Handles fvActivityHistory.DataBound
Dim row As FormViewRow = fvActivityHistory.Row
Dim tb As TextBox
Dim ddl As DropDownList
Dim lbl As Label
If fvActivityHistory.CurrentMode = FormViewMode.Insert Then
....bunch of code here....
ElseIf fvActivityHistory.CurrentMode = FormViewMode.Edit Then
tb = Page.Master.FindControl("txtProgramID")
If tb.Text = "4" Then
'FAP Rep Payee so show units to bill
tb = row.FindControl("txtUnits")
tb.CssClass = "Show"
lbl = row.FindControl("LblUnits")
lbl.CssClass = "Show"
Else
End If
End If
End Sub
I am getting the error
Object reference not set to an instance of an object.
It is happening on the tb = row.FindControl("txtUnits") line. Should I do
something more in the FindControl if the FormView is inside a
ContentPlaceHolder? Thanks.
David
to show or hide 2 controls based on a condition. Below is part of the
DataBound event code that I am having a problem with.
Protected Sub fvActivityHistory_DataBound(ByVal sender As Object, ByVal
e As System.EventArgs) Handles fvActivityHistory.DataBound
Dim row As FormViewRow = fvActivityHistory.Row
Dim tb As TextBox
Dim ddl As DropDownList
Dim lbl As Label
If fvActivityHistory.CurrentMode = FormViewMode.Insert Then
....bunch of code here....
ElseIf fvActivityHistory.CurrentMode = FormViewMode.Edit Then
tb = Page.Master.FindControl("txtProgramID")
If tb.Text = "4" Then
'FAP Rep Payee so show units to bill
tb = row.FindControl("txtUnits")
tb.CssClass = "Show"
lbl = row.FindControl("LblUnits")
lbl.CssClass = "Show"
Else
End If
End If
End Sub
I am getting the error
Object reference not set to an instance of an object.
It is happening on the tb = row.FindControl("txtUnits") line. Should I do
something more in the FindControl if the FormView is inside a
ContentPlaceHolder? Thanks.
David