views:

161

answers:

2

I have 50 checkboxes that I need to write onto an aspx page. Each checkbox comes with 3 textboxes.

Example:

chkbox State   Name   donation  new donation
chkbox CA      Sam     10        15
chkbox AK      Sam     15        20

Now this shall go for all 50 states, depending on which states the person wishes to donate. In each state's row shall be a checkbox. So initially the page shall have value 0.00 in donation and new donation checkboxes, but all 50 states shall be visible. When the person puts a value of donation in certain state, that state shall get "checked" value and the donation, after submitting. On reloading, the value shall be populated automatically and checkbox checked automatically.

  • How do I make these 50 checkboxes in VB.NET?
  • Do I have to write the table in .aspx with 50 <tr> tags, and then have VB.NET code populate it?
  • Can I otherwise dynamically write these checkboxes from VB.NET code?
+1  A: 

You don't need recursion for something like this. You need looping constructs like For or While.

You can create an array of checkboxes with a size of 50:

Dim checkboxs(50) as Checkbox
Oded
but every checkbox shall have 3 textboxes on the same row. could you write a little more descriptive example please? or a link to read. Thank you for your help
terr
I would recommend a UserControl like @hawbsl suggested. Here is some rough code of what @Oded was talking about Dim LotsOfCheckboxes(50) as CheckboxFor i as Integer = 0 to ListOfCheckBoxes.Count -1LotsOfCheckBoxes.(i) = New CheckboxLotsOfCheckBoxes.Checked = True Page.Controls.Add(ListOfCheckBoxes(i))End For
bluecoder
+1  A: 

To handle the fact that each checkbox comes with three textboxes consider creating a UserControl.

There are lots of example tutorials out there. Here's one.

hawbsl