ASP.NET: Asign Users in Roles(Array.IndexOf(Of String) method)

Discussion in 'Software' started by msandlana, Apr 25, 2008.

  1. msandlana


    Apr 10, 2008
    Likes Received:
    South Africa, Cape Town
    Can anyone help me with this code below I downloaded and this line does not work coz I'm using ASP.NET 2.0 I'm still new on Is there anyone who know the Array.IndexOf(Of String) method

    The Linq.Enumerable.Contains(Of String)(...) syntax will not compile if you are using ASP.NET version 2.0. The Contains(Of String) method is part of the LINQ library, which is new to ASP.NET 3.5. If you are still using ASP.NET version 2.0, use the Array.IndexOf(Of String) method instead

    Private Sub CheckRolesForSelectedUser()
    ' Determine what roles the selected user belongs to
    Dim selectedUserName As String = UserList.SelectedValue
    Dim selectedUsersRoles() As String = Roles.GetRolesForUser(selectedUserName)

    ' Loop through the Repeater's Items and check or uncheck the checkbox as needed
    For Each ri As RepeaterItem In UsersRoleList.Items
    ' Programmatically reference the CheckBox
    Dim RoleCheckBox As CheckBox = CType(ri.FindControl("RoleCheckBox"), CheckBox)
    ' See if RoleCheckBox.Text is in selectedUsersRoles
    If Linq.Enumerable.Contains(Of String)(selectedUsersRoles, RoleCheckBox.Text) Then
    RoleCheckBox.Checked = True
    RoleCheckBox.Checked = False
    End If Next End Sub
    msandlana, Apr 25, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.