我使用过 ASP 的 CheckBoxList
控件。现在我想要的是在 VB 代码中获取所有选定的值。
HTML
<asp:CheckBoxList ID="chkbxlst_Users" runat="server" RepeatColumns="2" RepeatDirection="Vertical" RepeatLayout="Table"></asp:CheckBoxList>
VB
Protected Sub btnSaveSetProject_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveSetProject.Click
Dim ds_selectedProjects As New DataSet
Dim eStr As String = String.Empty
Try
Catch ex As Exception
Me.ShowErrorMessage(ex.Message, "...btnSaveSetProject")
End Try
End Sub
单击“保存”按钮后,我想获取数据集中所有选定项目的值和文本。
最佳答案
试试这个..
For Each li As ListItem In chkbxlst_Users.Items
If li.Selected Then
// add item data into your dataset
Else
// do whatever you need
End If
End If
Next
关于asp.net - 在 VB.NET 中获取 CheckBoxList 的所有选中值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21988757/