0

I have a gridview that contains a checkbox and a textbox. My objective is to disable the textbox as long as the user hasn't check the checkbox beside it. I am using RowDataBound Event but I think I'm missing some steps. This code is not firing. Please advise.

  Protected Sub GV_1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)


    Dim drview As DataRowView = TryCast(e.Row.DataItem, DataRowView)
    If e.Row.RowType = DataControlRowType.DataRow Then


        Dim SFtxt As TextBox = DirectCast(e.Row.FindControl("TB_AdjustSF"), TextBox)
        Dim adjSF As Double = SFtxt.Text
        'Find checkbox and checked/Unchecked based on values
        Dim chkb As CheckBox = DirectCast(e.Row.FindControl("selectitem"), CheckBox)

        If chkb.Checked = True Then
            SFtxt.Enabled = True

        Else
            SFtxt.Enabled = False

        End If

    End If
End Sub

Thanks in advance.

lulutanseco
  • 313
  • 1
  • 8
  • 29
  • Try adding a Handles clause to the end of the Sub line.... Protected Sub GV_1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GV_1.RowDataBound – Mych Jun 16 '14 at 09:53
  • I tried it. However, it seems like the page load event is affected. The gridview won't load properly on page load. – lulutanseco Jun 17 '14 at 00:55
  • What error do you get? The more information you post the easier it will be to help. – Mych Jun 17 '14 at 11:23

0 Answers0