G
Guest
I have a listbox inside of a DetailsView. There are three departments to
choose from, Corporate, Group, Vacation. The listbox is set to
SelectionMode="multiple". I think I have this loop setup correctly, the
problem is as it is looping through it outputs the same value even though
watching it validate each value - false, true, true - it repeats the value
for the first "true" item it comes across.
For instance if I choose Group and Vacation, it validates as false, true,
true, but outputs - Group, Group,
Here is my code:
Protected Sub CheckRequestDetailsView_ItemInserting(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles
CheckRequestDetailsView.ItemInserting
Dim DepartmentListBox As ListBox
DepartmentListBox = CheckRequestDetailsView.FindControl("DepartmentListBox")
Dim DepartmentString As String = ""
Dim Item As ListItem
For Each Item In DepartmentListBox.Items
If Item.Selected Then
DepartmentString += DepartmentListBox.SelectedItem.ToString +
", "
End If
Next
CheckRequestSqlDataSource.InsertParameters(
"DepartmentsCharged").DefaultValue = DepartmentString
End Sub
choose from, Corporate, Group, Vacation. The listbox is set to
SelectionMode="multiple". I think I have this loop setup correctly, the
problem is as it is looping through it outputs the same value even though
watching it validate each value - false, true, true - it repeats the value
for the first "true" item it comes across.
For instance if I choose Group and Vacation, it validates as false, true,
true, but outputs - Group, Group,
Here is my code:
Protected Sub CheckRequestDetailsView_ItemInserting(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles
CheckRequestDetailsView.ItemInserting
Dim DepartmentListBox As ListBox
DepartmentListBox = CheckRequestDetailsView.FindControl("DepartmentListBox")
Dim DepartmentString As String = ""
Dim Item As ListItem
For Each Item In DepartmentListBox.Items
If Item.Selected Then
DepartmentString += DepartmentListBox.SelectedItem.ToString +
", "
End If
Next
CheckRequestSqlDataSource.InsertParameters(
"DepartmentsCharged").DefaultValue = DepartmentString
End Sub