473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Array not working properly

Expand|Select|Wrap|Line Numbers
  1. ' Determine what roles the selected user belongs to      
  2.         Dim strSelectedUserName As String = ddlUserList.SelectedValue
  3.         Dim strSelectedUsersRoles() As String = Roles.GetRolesForUser(strSelectedUserName)
  4.         Dim strRoleNames() As String = Roles.GetAllRoles.Clone
  5.  
  6.         ' Loop through the Repeater's Items and check or uncheck the checkbox as needed      
  7.         For Each ri As RepeaterItem In rptrUsersRoleList.Items
  8.  
  9.             ' Programmatically reference the CheckBox           
  10.             Dim RoleCheckBox As CheckBox = CType(ri.FindControl("RoleCheckBox"), CheckBox)
  11.  
  12.  
  13.             ' See if RoleCheckBox.Text is in selectedUsersRoles           
  14.             If Array.IndexOf(strSelectedUsersRoles, RoleCheckBox.Text) Then
  15.                 RoleCheckBox.Checked = True
  16.             Else
  17.                 RoleCheckBox.Checked = False
  18.             End If
  19.         Next
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.
Mar 28 '08 #1
1 1238
mafaisal
142 100+
Hello
U just change the line 2 to
Expand|Select|Wrap|Line Numbers
  1.  Dim strSelectedUserName As integer = ddlUserList.SelectedValue
Then try

Faisal

Expand|Select|Wrap|Line Numbers
  1. ' Determine what roles the selected user belongs to      
  2.         Dim strSelectedUserName As String = ddlUserList.SelectedValue
  3.         Dim strSelectedUsersRoles() As String = Roles.GetRolesForUser(strSelectedUserName)
  4.         Dim strRoleNames() As String = Roles.GetAllRoles.Clone
  5.  
  6.         ' Loop through the Repeater's Items and check or uncheck the checkbox as needed      
  7.         For Each ri As RepeaterItem In rptrUsersRoleList.Items
  8.  
  9.             ' Programmatically reference the CheckBox           
  10.             Dim RoleCheckBox As CheckBox = CType(ri.FindControl("RoleCheckBox"), CheckBox)
  11.  
  12.  
  13.             ' See if RoleCheckBox.Text is in selectedUsersRoles           
  14.             If Array.IndexOf(strSelectedUsersRoles, RoleCheckBox.Text) Then
  15.                 RoleCheckBox.Checked = True
  16.             Else
  17.                 RoleCheckBox.Checked = False
  18.             End If
  19.         Next
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.
Mar 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
12
by: Treetop | last post by:
I cannot get this array to work. I want to have the game listed until the day after the event, then come off the list. function events() { var today = new Date(); var dayarray=new...
2
by: J. J. Cale | last post by:
In IE6 both these functions *seem* to be working. I don't see much recursion in this group except the occasional setTimeout problems. Besides the obvious stack problems that can occur if one...
10
by: Kieran Simkin | last post by:
Hi, I wonder if anyone can help me, I've been headscratching for a few hours over this. Basically, I've defined a struct called cache_object: struct cache_object { char hostname; char ipaddr;...
12
by: natkw1 | last post by:
Hi, I'm attempting to understand the use of pointers(at least grasp how pointers work). I've read the FAQ on http://www.eskimo.com/~scs/C-faq/s6.html on pointers and arrays but I'm still a bit...
29
by: yourmycaffiene | last post by:
Okay, this if my first post so go easy on me plus I've only been using C for a couple of weeks. I'm working on a program currently that requires me to read data from a .dat file into a 2d array and...
7
by: Sam | last post by:
Hello I have a structure called Company. struct Company { char *employee; char *employee_address; }; I want to build an array of this structure but the number of employees will change...
29
by: tnspc | last post by:
I'm writing code for a class where I've set up functions to load data from a file in the same directory as the PHP file (using the "file" method). Then, the goal is for the program to take the info...
9
by: JackpipE | last post by:
I need to create multidimensional array with arrays inside of it. database name | value1 | value2 john | red | 45 john | red | 56 john | yellow | 11 mike | blue | 23 mike | black | 41
152
by: vippstar | last post by:
The subject might be misleading. Regardless, is this code valid: #include <stdio.h> void f(double *p, size_t size) { while(size--) printf("%f\n", *p++); } int main(void) { double array = { {...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.