New to asp.net. Pretty familiar with vb.net. This maybe a simple question but I can't seem to find a good answer to it anywhere or at least an alternative/better way.
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.
Now I can't get the data back after submitting the form. It is really easy to work with the controls that are created in the design view. But I don't know how to work with the controls created in the code.
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:
It is really easy to work with controls that are created in the design view. I just can't find out how to get the data from the controls that are created in the code.
Also is there a method for view all the post back data from the form? Something like:
response.write me.form1.postba ckdata
Thanks for your help!
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.
Code:
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:
Code:
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.postba ckdata
Thanks for your help!
Comment