Dynamic CheckBoxes and TextBoxes
Posted on 2004-08-25
Problem Description :
I have Test types in SQL database.
Table name :- tableTest ( testID, TestDesc)
Data in tableTest
100 - Test 1, 200 - Test 2, 300 - Test 3, 400 - Test 4 and so on......
Where 100,200 etc are testID and
Test1, Test2 etc are testDesc
I am showing these tests on Web data input form as check boxes as user can select more than one test types.
i am using checkboxlist to populate tests from tableTest
I take all the tests from the test box and make a string. then convert string to array and load the array in checkboxlist
Dim strPerTestTypes As String
strPerTestTypes = "Per"
Dim myDataReaderTestDetailsPer As SqlClient.SqlDataReader = SqlCommandPerTestDetails.ExecuteReader()
strPerTestTypes = strPerTestTypes + "," + myDataReaderTestDetailsPer.Item("testdesc")
Dim arrPerTest() As String = Split(strPerTestTypes, ",")
Dim i As Integer
For i = 1 To UBound(arrPerTest)
perCheckBoxList.RepeatColumns = "6"
This way i get all the checkboxes that i want.
The problem is that i need textboxes associated with every check box.
The user is supposed to enter comments for every test selected.
If the user selects Test 1 check box, he will write comments against test 1 check box. ( in the text box)
Checkbox Test 1 checked .. comments in the corresponding textbox "Test at full load"
Check box Test 2 checked .. comments in the corresponding text box "Test for leaks"
Number of text boxes should be exactly same as check boxes and should be lined right next to check box .
User is forced to fill the text box if the check box is checked. ( for every checked checkbox, there has to be comments in the corresponding text box)
Once the user submits form, i have to collect all the data and save in database.
Thanks in advance