Dynamically outputting checkboxes to aspx page in VB.NET
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开发者_如何学C 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?
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
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.
精彩评论