A
Andreas Wöckl
Hi Group!
I have a web form that is created dynamically - so I create Textboxes,
RadioButtonLists, CheckBoxLists and so on - I have found some articles that
there may be some problems with postback - but if I press a submit button
the textboxes keep the value. My problem is the following:
I would like to use this Code to collect the data:
'Collects values - is calles from a button
Private Sub collectValues()
Dim page As Control
Dim ctl As Control
Dim table As Table
Dim row As Control
Dim cell As TableCell
Dim dataControl As Control
Dim mpContentPlaceHolder As ContentPlaceHolder
mpContentPlaceHolder = CType(Master.FindControl("content"),
ContentPlaceHolder)
Dim mp As MultiPage
mp = CType(mpContentPlaceHolder.FindControl("mp"), MultiPage)
'Debug.Print("vieSTateval " & Me.ViewState("TextBox1").ToString)
For Each ctl In mp.Controls ' Pages!
If TypeOf ctl Is PageView Then
If ctl.Controls.Count > 0 Then
table = ctl.Controls(0)
For Each row In table.Controls
If row.Controls.Count > 1 Then
cell = row.Controls(1)
dataControl = cell.Controls(0)
' if i make an output of the ID all controls are
iterated!!!
Debug.Print("value of " & dataControl.ID & " is "
& getDataCellValue(dataControl)
End If
Next
End If
End If
Next
For Each ctl In Me.Form.Controls
'Debug.Print("Name " & ctl.ID & " value " & ctl.ToString)
Next
End Sub
Private Function getDataCellValue(ByRef ctl As Control) As String
Dim t As TextBox
If TypeOf ctl Is TextBox Then
t = CType(ctl, TextBox)
getDataCellValue = t.ToString
ElseIf TypeOf ctl Is RadioButtonList Then
ElseIf TypeOf ctl Is CheckBoxList Then
End If
End Function
I always get the following output: "value of [id] is " - So when iterating
the controls I can not access the values - but I still can see them in the
form after the postback!
Anyone an idea?
best regards
Andy
I have a web form that is created dynamically - so I create Textboxes,
RadioButtonLists, CheckBoxLists and so on - I have found some articles that
there may be some problems with postback - but if I press a submit button
the textboxes keep the value. My problem is the following:
I would like to use this Code to collect the data:
'Collects values - is calles from a button
Private Sub collectValues()
Dim page As Control
Dim ctl As Control
Dim table As Table
Dim row As Control
Dim cell As TableCell
Dim dataControl As Control
Dim mpContentPlaceHolder As ContentPlaceHolder
mpContentPlaceHolder = CType(Master.FindControl("content"),
ContentPlaceHolder)
Dim mp As MultiPage
mp = CType(mpContentPlaceHolder.FindControl("mp"), MultiPage)
'Debug.Print("vieSTateval " & Me.ViewState("TextBox1").ToString)
For Each ctl In mp.Controls ' Pages!
If TypeOf ctl Is PageView Then
If ctl.Controls.Count > 0 Then
table = ctl.Controls(0)
For Each row In table.Controls
If row.Controls.Count > 1 Then
cell = row.Controls(1)
dataControl = cell.Controls(0)
' if i make an output of the ID all controls are
iterated!!!
Debug.Print("value of " & dataControl.ID & " is "
& getDataCellValue(dataControl)
End If
Next
End If
End If
Next
For Each ctl In Me.Form.Controls
'Debug.Print("Name " & ctl.ID & " value " & ctl.ToString)
Next
End Sub
Private Function getDataCellValue(ByRef ctl As Control) As String
Dim t As TextBox
If TypeOf ctl Is TextBox Then
t = CType(ctl, TextBox)
getDataCellValue = t.ToString
ElseIf TypeOf ctl Is RadioButtonList Then
ElseIf TypeOf ctl Is CheckBoxList Then
End If
End Function
I always get the following output: "value of [id] is " - So when iterating
the controls I can not access the values - but I still can see them in the
form after the postback!
Anyone an idea?
best regards
Andy