我有一个包含问题和一堆动态创建的单选按钮列表的表格,我正在尝试编写代码,该代码将遍历每个单选按钮列表并获取所选问题值和相应问题 id 的值。我有以下代码返回选定的单选按钮列表值。我将如何获取问题 ID 以及它们的选定值?
For Each ctrl As Control In form1.Controls
If TypeOf ctrl Is RadioButtonList Then
Dim rbl As RadioButtonList = DirectCast(ctrl, RadioButtonList)
For i As Integer = 0 To rbl.Items.Count - 1
If rbl.Items(i).Selected Then
Dim value As String = rbl.SelectedValue
End If
Next
End If
Next