0
我有一个DataGridView绑定到Oracle数据库并带有一个复选框列。这个想法是,当我选择一个复选框时,其余的会自动取消选中,或者找到一种方法来验证在按下“确认”按钮时只有一个复选框被选中。我可以获得复选框行的索引和值,但我无法将值设置为复选框。当在vb.net中选择一个复选框时,取消选中GridView中的所有复选框
这是我使用代码得到
Private Function GetSelectedRow() As Integer()
Dim Array As Integer() = {0, 0}
Dim index As Integer
Dim id_propuesta As Integer
For i As Integer = 0 To GridView3.Rows.Count - 1
Dim cb As CheckBox = DirectCast(GridView3.Rows(i).Cells(0).FindControl("CheckBox1"), CheckBox)
If cb IsNot Nothing Then
If cb.Checked Then
Dim hf As HiddenField = DirectCast(GridView3.Rows(i).Cells(0).FindControl("HiddenField1"), HiddenField)
If hf IsNot Nothing Then
id_propuesta = hf.Value
index = i
End If
Exit For
End If
End If
Next
Array(0) = index
Array(1) = id_propuesta
Return Array
End Function