チェックボックス列を持つOracleデータベースにバインドされたDataGridViewがあります。アイデアは、チェックボックスを1つ選択すると、残りのチェックボックスが自動的にオフになるか、「確認」ボタンを押したときに1つだけが選択されていることを検証する方法を見つけることです。チェックボックス行のインデックスと値を取得できますが、チェックボックスに値を設定できません。
これは私がgetに使用しているコードです
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