I am trying to dynamically create checkboxes for items that need to be selected and updated in the database.
The code below will allow those checkboxes to be created and display on the web form and work correctly. However, when I try to access them from another function/Sub I can not.
Expand|Select|Wrap|Line Numbers
- Private Sub GetData( orderNumber as integer)
- sqlQueryString = "exec OrderItems " & orderNumber
- Dim objDs As DataSet
- Dim objSQLDa As SqlDataAdapter
- Dim objRow As DataRow
- objDs = New DataSet()
- objSQLDa = New SqlDataAdapter(sqlQueryString, ConnString)
- objSQLDa.Fill(objDs, "Dropship Data")
- Dim chk(objDs.Tables(0).Rows.Count) As CheckBox
- i = 0
- For Each objRow In objDs.Tables(0).Rows
- sItemID = "<strong>ItemID:</strong> " & objRow("ItemID").ToString & "<br>" & CrLf
- sBrand = "<strong>Brand:</strong> " & objRow("Brand").ToString & "<br>" & CrLf
- sDropShip = "<strong>Dropship:</strong> " & objRow("dropship").ToString & "<br>" & CrLf
- chk(i) = New CheckBox
- chk(i).ID = objRow("id").ToString
- chk(i).Text = sItemID & sBrand & sDropShip
- Me.productData.Controls.Add(chk(i))
- i += i
- Next
- End Sub
I would like to check the boxes that are needed. Click a submit button. Then have the click button event handler loop through the ID's for the checked boxes and process a stored proc that will do all the updates in the DB that need to be done.
Something like:
Expand|Select|Wrap|Line Numbers
- Sub DoThisWhenTheButtonIsPressed()
- For i=0 to uBound(chk)
- if chk(i).checked then
- DoStoredProc(chk(i).ID)
- end if
- Next
- End Sub
Also is there a method for view all the post back data from the form? Something like:
response.write me.form1.postbackdata
Thanks for your help!