我有一个带有复选框列的Oracle数据库的DataGridView。我的想法是,当我选择一个复选框时,其余部分会自动取消选中,或者找到一种方法来验证在按下“确认”按钮时只有一个被选中。我可以获取复选框行的索引和值,但我无法将值设置为复选框。
这是我用于 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
答案 0 :(得分:0)
为什么不在组合框中组合单选按钮?虽然那会更好吗?
这句话的意思是Dim cb As CheckBox = DirectCast(GridView3.Rows(i).Cells(0).FindControl("CheckBox1"), CheckBox)
?从数据网格单元格中提取数据并将其分配给复选框??
你可以使用radD.Text = dgData.Rows(tracker1).DataBoundItem("OptionD").ToString
其中tracker1是列索引,“OptionD”是列名,radA.text是单选按钮中的文本。和dgData是数据网格视图的名称