I've got a checkbox list with 12 items to choose from. If one of them is chosen i postback and dynamically add 3 controls to a panel. Here's a snippet of the code i'm using...
For i = 0 to cblPatientGoals.Items.Count -1
If cblPatientGoals.Items(i).Selected
Dim myLabel as new Label ()
myLabel.Text &= cblPatientGoals.Items(i).Text
Dim myCheckBox as New CheckBoxList ()
myCheckBox.Items.Add(new ListItem("Met", "Met"))
myCheckBox.Items.Add(new ListItem("Unmet", "Unmet"))
myCheckBox.RepeatDirection = RepeatDirection.Horizontal
myCheckBox.ID = "cGoals" & (i + 1)
'Response.write(myCheckBox.id)
Dim myTextBox as New TextBox ()
myTextBox.ID = "tGoals" & (i + 1)
myTextBox.Style("Width") = "350px"
panel1.Controls.Add(myLabel)
panel1.Controls.add(myCheckBox)
panel1.Controls.add(myTextBox)
End If
Next
All of this works as intended. When a user clicks the first item in the checkboxlist i have a label created, a checkboxlist with 2 listitems Met and Unmet created as well as a textbox. The respective ID's of that checkboxlist and textbox is cgoals1 and tgoals1. My dilemma is this...how do i update a database?
In my table i have 24 fields (cgoals1, tgoals1, cgoals2, tgoals2 etc) however i'm stuck writing the INSERT INTO statement b/c i'm dynamically creating controls which are dependent on what the user clicks.
I'm looking for some ideas on either how to update this or a better method of doing what i'm doing...i'm fully open to any suggestions anyone can give me.
Thanks
dc.
For i = 0 to cblPatientGoals.Items.Count -1
If cblPatientGoals.Items(i).Selected
Dim myLabel as new Label ()
myLabel.Text &= cblPatientGoals.Items(i).Text
Dim myCheckBox as New CheckBoxList ()
myCheckBox.Items.Add(new ListItem("Met", "Met"))
myCheckBox.Items.Add(new ListItem("Unmet", "Unmet"))
myCheckBox.RepeatDirection = RepeatDirection.Horizontal
myCheckBox.ID = "cGoals" & (i + 1)
'Response.write(myCheckBox.id)
Dim myTextBox as New TextBox ()
myTextBox.ID = "tGoals" & (i + 1)
myTextBox.Style("Width") = "350px"
panel1.Controls.Add(myLabel)
panel1.Controls.add(myCheckBox)
panel1.Controls.add(myTextBox)
End If
Next
All of this works as intended. When a user clicks the first item in the checkboxlist i have a label created, a checkboxlist with 2 listitems Met and Unmet created as well as a textbox. The respective ID's of that checkboxlist and textbox is cgoals1 and tgoals1. My dilemma is this...how do i update a database?
In my table i have 24 fields (cgoals1, tgoals1, cgoals2, tgoals2 etc) however i'm stuck writing the INSERT INTO statement b/c i'm dynamically creating controls which are dependent on what the user clicks.
I'm looking for some ideas on either how to update this or a better method of doing what i'm doing...i'm fully open to any suggestions anyone can give me.
Thanks
dc.