If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Dynamic Control Data Retrieval?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-20-02, 16:59
adron_bh adron_bh is offline
Junior Member
 
Join Date: Nov 2002
Location: United States (Various Cities and Locations)
Posts: 4
Question Dynamic Control Data Retrieval?

I created some controls via a placeholder control, they are simple check box controls. My code is as follows, but I do not get the objControl.Checked value? Am I doing this wrong somehow? At the wrong point in the page display/refresh/reload process? Any help is greatly appreciated!

Thanks,
ABH

FIRST - The code that generates the controls...

Dim dadPrimary As SqlDataAdapter, dadSecondary As SqlDataAdapter,dadTertiary As SqlDataAdapter, dadAdministrators As SqlDataAdapter
Dim intPrimaryCounter As Integer, intSecondaryCounter As Integer, intTertiaryCounter As Integer
Dim intCheckCount As Integer
'Declare Control Objects
Dim litLabel As LiteralControl
Dim chkCheckBox As CheckBox
'Connect and fill the dataset with the dataadapters.
Connect()
dadPrimary = New SqlDataAdapter(strSQL1, objConn)
dadPrimary.Fill(dsPrimary, "1Primary")
Disconnect()
'Start looping
intPrimaryCounter = 0
Do While intPrimaryCounter < dsPrimary.Tables("1Primary").Rows.Count
litLabel = New LiteralControl() 'Add Control
litLabel.Text = "<b>" & dsPrimary.Tables("1Primary").Rows(intPrimaryCounte r).Item("strItemName") & ":</b>
"
litLabel.ID = "Pri_" & intPrimaryCounter
plhPrimary.Controls.Add(litLabel)
'List Sub Items
Connect()
dadSecondary = New SqlDataAdapter(strSQL2, objConn)
dadSecondary.SelectCommand.Parameters.Add("@PKFK", dsPrimary.Tables("1Primary").Rows(intPrimaryCounte r).Item("intPK_id"))
dadSecondary.Fill(dsPrimary, "2Secondary")
Disconnect()
intSecondaryCounter = 0
Do While intSecondaryCounter < dsPrimary.Tables("2Secondary").Rows.Count
litLabel = New LiteralControl()
litLabel.Text = " " 'Add spaces for a tab
litLabel.Text &= "<i>" & dsPrimary.Tables("2Secondary").Rows(intSecondaryCo unter).Item("strSubItemName") & " - </i>
"
litLabel.ID = "Pri_Sec_" & intPrimaryCounter & "_" & intSecondaryCounter
plhPrimary.Controls.Add(litLabel)
'List Tertiary Check Box Items
Connect()
dadTertiary = New SqlDataAdapter(strSQL3, objConn)
dadTertiary.SelectCommand.Parameters.Add("@PK_FK", dsPrimary.Tables("2Secondary").Rows(intSecondaryCo unter).Item("intPK_id"))
dadTertiary.Fill(dsPrimary, "3Tertiary")
Disconnect()
intTertiaryCounter = 0
Do While intTertiaryCounter < dsPrimary.Tables("3Tertiary").Rows.Count
chkCheckBox = New CheckBox()
intCheckCount = dsPrimary.Tables("3Tertiary").Rows.Count - 1
If intTertiaryCounter = intCheckCount Then
chkCheckBox.Text = dsPrimary.Tables("3Tertiary").Rows(intTertiaryCoun ter).Item("strAccessName") & "<br>"
Else
chkCheckBox.Text = dsPrimary.Tables("3Tertiary").Rows(intTertiaryCoun ter).Item("strAccessName")
End If
chkCheckBox.EnableViewState = False
chkCheckBox.ID = "Pri_Sec_Ter" & intPrimaryCounter & "_" & intSecondaryCounter & "_" & intTertiaryCounter
plhPrimary.Controls.Add(chkCheckBox)
intTertiaryCounter += 1
Loop
dsPrimary.Tables("3Tertiary").Clear()
intSecondaryCounter += 1
Loop
dsPrimary.Tables("2Secondary").Clear()
intPrimaryCounter += 1
Loop


----------------------------------------------------------------
Then the code that is attempting to retrieve the data entered in the form controls.
----------------------------------------------------------------

Private Sub btnIssueRequest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIssueRequest.Click
Dim intCounter As Integer
Dim objControl As Object
Dim strName As String
Dim blnChecked As Boolean
Dim chkCheckBox As CheckBox

intCounter = 0
Do While intCounter < plhPrimary.Controls.Count
objControl = plhPrimary.Controls.Item(intCounter)
strName = objControl.clientid

If strName.StartsWith("Pri") Then
Response.Write(objControl.text & "<br>")
ElseIf strName.StartsWith("Pri_Sec") Then
Response.Write(objControl.text & "<br>"
Else
Response.Write(objControl.Text)
Response.Write(objControl.checked.ToString)
Response.Write(objControl.Checked.Parse)
Response.Write(objControl.Checked.GetType.FullName & "<br>")
Response.Write(objControl.GetType)
End If
intCounter += 1
Loop

End Sub
__________________
ABH
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On