CheckBox GridView 動態產生


   Protected Sub gv_account_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gv_account.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim ck = New CheckBox
            ck.ID = "Scheck"
            e.Row.Cells(1).Controls.Add(ck)
        End If
    End Sub

抓值方式

Sub PermissionCheck()
        Dim gvr As GridViewRow
        Dim KeyName As String

        For Each gvr In gv_account.Rows
            Dim cb As CheckBox = CType(gvr.FindControl("Scheck"), CheckBox)

            If cb.Checked = True Then
                KeyName = gv_account.DataKeys(gvr.RowIndex).Values(0)
            End If

        Next

    End Sub

留言

這個網誌中的熱門文章

VB 檢查數字