views:

372

answers:

2

i have 50 checkboxes for 50 american states. The user can choose all 50 or only 1( so basically any number he wants). Based on his choice, I want to insert or update the table in sql server 2008. e.g-

Color = blue and chk1=check, chk2= check and chk3 = check (chk = checkbox). now the user wants to ad 10 more states to this or remove these 3 and add 5 more. so u basically get the idea. the table in database looks like this - ID Color State_id there is a table called states, so stateid shall come from there. so how do i do a loop insert or update in vb.net?

A: 

This might not be answering your question directly... but you may want to consider using a checked listbox of 50 entries rather than 50 discreet checkboxes. At least this way you will be able to loop through the CheckedItems collection updating whatever it is you want to do.

Bill
A: 

You can use an array of checkboxes and process them through a loop. There are a couple of ways to do this. One, assign each element in an array of checkboxes to one of the 50 you put on the form in design mode. Two, you can create a new checkbox for each array element at runtime as position it on the form. With the second method, you don't need to add the checkboxes in design mode.

xpda