I have a repeater with about 100 rows, and 4 columns in each row. something like this table:
Username HasIpod HasGymMembership HasCar
``````````````````````````````````````````````````````````````
User1 chcekbox checkbox checkbox
User2 chcekbox checkbox checkbox
User3 chcekbox checkbox checkbox
User4 chcekbox checkbox checkbox
well, you get the idea.
The admin can tick/untick any box anytime and click on a “Save” button at the end of page and thats when I need to update the database. I need to add a row in one of the table if a certain checkbox is checked, delete it if its unchecked.
I can just loop through the repeater and VERY EASILY do it with each row. but my concern is that, at the worst case, this will use about 100 rows X 3 = 300 database accesses. Thats bad right?
I thought of concatenating all values into a form of csv.. something like:
user1id,1,0,1;user1id,0,1,1
just a list of userid, its values separated with , and the next user’s values separated with ; and in the database I can just use a split function and a bunch of while loop and update accordingly.
but It just doesnt satisfy me for some reason. Is there a better way to deal with a such a situation? I am sure this is not a unique case, what do you guys do in a scenario? any insight about being a super fast “ninja” in this (with as little db access as possible) would be great.
thanks.
instead of csv you can use xml, like this:
UPDATE:
another way, assuming you use dirty state
that’s of course assuming you have 3 tables (
ipod,gym,car). if not, then just update theUserstable