473,769 Members | 3,102 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

c# checked list box help

23 New Member
Ok I fill a CheckedListBox this way


clbRoles.DataSo urce = objSecurity.Ret urnRoleList();
clbRoles.Displa yMember = "RoleName";
clbRoles.ValueM ember = "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.SetIte mChecked(x, objSecurity.Ans werUserHasRole( 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.Get ItemCheckState( i) == CheckState.Chec ked)
{
objSecurity.Add UserRole(strUse rID, clbRoles.Select edValue.ToStrin g());
}
else
{
//objSecurity.Del eteUserRole(str UserID, clbRoles.Select edValue.ToStrin g());
objSecurity.Del eteUserRole(str UserID, clbRoles.Items[i].ToString());
}
}
Apr 30 '07 #1
0 2492

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

Similar topics

26
2824
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 - Specified argument was out of the range of valid values. Parameter name: '-1' is not a
0
306
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 Message----- >Hello, > >I am having some trouble getting a checked list box to >behave the way i would like. Here is my situation. I >would like to load up a dynamic list of phone numbers.
3
1160
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" CheckedListBox1.DisplayMember = "State" "State" is the column in the table... And the above works fine... All the states are shown in the CheckedListBox
2
1596
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 client-side(using JavaScript) but always I get a value "undefined"....this code works for all other controls except checkboxlist and radiobuttonlist controls. I am pasting my code below Please let me know wht am i doing wrong.
2
2320
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 checkbox join/link that is in the database. So, the insert/checked is working, but the "unchecking" is not working. I don't know how to compare an array of what was not checked. Here is my code: if (is_array($_POST)) {
1
2013
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 that is checked is to be run. I'm looking for an elegant and extensible way to do this. I'm currently using an if block, which just seems silly to me. Structurally, it's the equivalent of the below. Any ideas on alternatives would be much
4
34076
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 checkboxes and the rows numbers
2
7136
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 are in MFC I have to remain constrained only in C#. I have tried to add checked listbox in combobox drop down list but it is showing in text format i.e. name of the control added, if I change display property of combobox with some property of...
0
4101
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 with my problems. Now for my new little problem,I had a problem posting the values from checkbox fields to a database and thats the obstacle I overcame. Now the second part is my new problem is that I want that the next time that page loads for...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.