Hello, I'm using the attached code to remove items from a ddl based on not being in a list. When loop through the ddl removing items I get to the last item and get the following error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
On this Line:
What am I missing here?
'perform platform security check on ddl platforms
'first get the users username from his profile
Dim userProfile As ProfileCommon = Profile.GetProfile(HttpContext.Current.User.Identity.Name)
Dim AuthorizedPlatformList As IList = PlatformSecurityManager.GetPlatformSecurityByUsername(userProfile.Username)
'loop through the authorized platform list and remove all platforms from the ddl that are not in the list
For Each r As PlatformSecurity In AuthorizedPlatformList
For x As Integer = ddlPlatforms.Items.Count - 1 To 0 Step -1
Dim item As ListItem = ddlPlatforms.Items(x)
If item.Value <> "Select Platform" Then
If item.Value <> r.PlatformName Then