[code=vb]' Determine what roles the selected user belongs to
Dim strSelectedUser Name As String = ddlUserList.Sel ectedValue
Dim strSelectedUser sRoles() As String = Roles.GetRolesF orUser(strSelec tedUserName)
Dim strRoleNames() As String = Roles.GetAllRol es.Clone
' Loop through the Repeater's Items and check or uncheck the checkbox as needed
For Each ri As RepeaterItem In rptrUsersRoleLi st.Items
' Programmaticall y reference the CheckBox
Dim RoleCheckBox As CheckBox = CType(ri.FindCo ntrol("RoleChec kBox"), CheckBox)
' See if RoleCheckBox.Te xt is in selectedUsersRo les
If Array.IndexOf(s trSelectedUsers Roles, RoleCheckBox.Te xt) Then
RoleCheckBox.Ch ecked = True
Else
RoleCheckBox.Ch ecked = False
End If
Next[/code]
The code above is supposed to populate check boxes from a repeater in .Net that contains User Roles. For some reason though on the first entry the first time through the code it does not check the box "administrator" , which it should.
Dim strSelectedUser Name As String = ddlUserList.Sel ectedValue
Dim strSelectedUser sRoles() As String = Roles.GetRolesF orUser(strSelec tedUserName)
Dim strRoleNames() As String = Roles.GetAllRol es.Clone
' Loop through the Repeater's Items and check or uncheck the checkbox as needed
For Each ri As RepeaterItem In rptrUsersRoleLi st.Items
' Programmaticall y reference the CheckBox
Dim RoleCheckBox As CheckBox = CType(ri.FindCo ntrol("RoleChec kBox"), CheckBox)
' See if RoleCheckBox.Te xt is in selectedUsersRo les
If Array.IndexOf(s trSelectedUsers Roles, RoleCheckBox.Te xt) Then
RoleCheckBox.Ch ecked = True
Else
RoleCheckBox.Ch ecked = False
End If
Next[/code]
The code above is supposed to populate check boxes from a repeater in .Net that contains User Roles. For some reason though on the first entry the first time through the code it does not check the box "administrator" , which it should.
Comment