CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2008
    Posts
    4

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

    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 asp.net. 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
    Else
    RoleCheckBox.Checked = False
    End If Next End Sub

  2. #2
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210

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

    Hello
    Instead of this line:
    Code:
     If Linq.Enumerable.Contains(Of String)(selectedUsersRoles, RoleCheckBox.Text) Then
    Use:
    Code:
    If Array.IndexOf(Of String)(selectedUsersRoles, RoleCheckBox.Text) > -1 Then
    Hesham A. Amin
    My blog , Articles


    <a rel=https://twitter.com/HeshamAmin" border="0" /> @HeshamAmin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured