checkBoxes help - too many

SteveInBeloit

Well-known member
Joined
May 22, 2006
Messages
132
Programming Experience
10+
HI,

I have an ASP .NET page that collects warranty information, name, address, etc. I gather the info, validate it with validation controls, then call a Stored Proc on SQL 2005 passing the data as parameters that does the inserts.

Now I have to put check boxes on it for the users to check. 69 of them!! I don't want to add 69 more parameters to my stored proc. So, here is what I am thinking. I would like some input as to is this sounds OK, and how to do some of it.

Put all the check boxes on the page.

Add one parameter to the stored proc, a string. As I interrogate the checkboxes, build a string full of 1's and 0's (on and offs). Pass that to the proc, and let it sort them out. Yes, positions will be VERY important. Sound OK? Is there a way to do this in a loop, and not one at a time?


I have heard of the StringBuilder class, I will look that up, and hope it can help in building the string. Sound OK?

I will want a "Check All" button. If that is set, I will pass a string of all 1's (ons).

Is there a way to check all checkboxes on the page when they push this button? And a way to reset them all for the next user?

Thanks for any help thrown my way. I think I know what I want to do, just not 100% sure on how to do it.

Steve
 
so you have like 69 options for users to check and want to store them all in one field?

Sounds like a similar thing I did before. I pulled the options from a table and put the row id in the checkbox's value. When the users saved the data, I stored all the checked values in a comma separated string.

That's kind of nice because when I go to retrieve it my sql statement looks like

VB.NET:
Expand Collapse Copy
"select * from tablename where rowid in [" + theoptions + "]"

where theoptions is like "1,2,3,6,9"
 
Back
Top