Update selected checkboxlist data to database

Posted on 2005-03-25
Medium Priority
Last Modified: 2012-05-05
Here is the situation:

I databind a checkboxlist with a user permission table in database to get a full list of available permissions, then I use datareader to get a specific user's permissions to populate the previous checkboxlist, then the admin can add and/or remove the user's permissions, then click "Update" button to update the user's permissions. My question is how I do the update part? How do I know which is added and which is removed?

Thank you very much,

Question by:prairiedog

Accepted Solution

LandyJ earned 750 total points
ID: 13631217
Are you looking for code or suggestions on method?

You can do it a couple of ways.  One, keep a dataset of existing permissions and compare it to the updated dataset, then change the values accordingly.  Two, on Update, set all permissions to "Off", then use the CheckedItems collection of the CheckBoxList control and set those Persissions "On"  

I'm sure there are other ways too, but these ar the two methods I usually use, with a strong leaning towards option 2.  It's more definite as to what is set On after processing is completed.
LVL 22

Author Comment

ID: 13727368
Sorry for my late replay. I actually figured out how to do it, but your reply really gave me a confirmation of what I wanted to do. So you got my 250 points.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question