ASP.NET中GridView上的RowDataBound事件

时间:2014-06-16 08:48:12

标签: asp.net vb.net gridview checkbox rowdatabound

我有一个包含复选框和文本框的gridview。我的目标是禁用文本框,只要用户没有选中它旁边的复选框即可。我正在使用RowDataBound事件,但我想我错过了一些步骤。此代码未触发。请指教。

  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

提前致谢。

0 个答案:

没有答案