473,394 Members | 1,965 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,394 software developers and data experts.

c# checked list box help

23
Ok I fill a CheckedListBox this way


clbRoles.DataSource = objSecurity.ReturnRoleList();
clbRoles.DisplayMember = "RoleName";
clbRoles.ValueMember = "RoleID";

#1 Issue: I want to select certain items in those list for roles the user already has. I tried the following but the last part doesn't work. How do I get the ID of the item as I am looping through?

for (int x = 0; x <= clbRoles.Items.Count; x++)
{
clbRoles.SetItemChecked(x, objSecurity.AnswerUserHasRole(strUserID, clbRoles.Items[x].ToString()));
}


#2 Issue: I want to then loop through each one again and do something for all the checked and do something for all the not checked ones. I am trying but again I can't seem to get the id from the item as I am looping, How do I get the ID??

for (int i=0; i< clbRoles.Items.Count; i++)
{
if(clbRoles.GetItemCheckState(i) == CheckState.Checked)
{
objSecurity.AddUserRole(strUserID, clbRoles.SelectedValue.ToString());
}
else
{
//objSecurity.DeleteUserRole(strUserID, clbRoles.SelectedValue.ToString());
objSecurity.DeleteUserRole(strUserID, clbRoles.Items[i].ToString());
}
}
Apr 30 '07 #1
0 2466

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

Similar topics

26
by: Simon Jefferies | last post by:
Hello, I am trying to add an item to a checked list box, like: clbList.Items.add("Hello",true) I get an error back: Run-time exception thrown: System.ArgumentOutOfRangeException -...
0
by: adam | last post by:
A simple solution would be to have them double click a name in the list and just add the selected item to a seperate textbox, doing anything DB related in the double click event. >-----Original...
3
by: Rob | last post by:
I am doing something wrong... I am populating a Checked List box from a stored proc... CheckedListBox1.DataSource=dsStates.Tables("States") CheckedListBox1.DisplayMember = "State"...
2
by: rishabhshrivastava | last post by:
Hi All, I am using CallBack feature in ASP.NET 2.0 and I am running into a problem with checkboxlist control. I have to find out which checkboxes are checked and get their values at...
2
by: Aaron Reimann | last post by:
I have a lot of check boxes. This is an update of the check boxes, I want something was checked, then to do an insert (which is currently working), if something is no longer checked...delete the...
1
by: sherifffruitfly | last post by:
Hi, I've got a checked list box, and a "go' button on the form. Each item in the checked list box is associated with a program (say notepad, calc, etc.). When the user clicks "go", every item...
4
by: Annie | last post by:
hello guys, I am having a DataGridView control. The first column is a checkbox column. The users can select the checkbox column. I need to loop through the grid rows and get the checked...
2
by: saurabhnsit2002 | last post by:
Can anyone help me about how to create combo box with its items as checked boxes or radio buttons. This has to be done in C#. I have seen something similar to this named custom combo boxes but they...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.