Fange værdi fra dynamisk control inden nye dynamisk controls afvikles
Vil gerne kunne fange værdier af vilkårlige dynamiske controls inden, næste sæt af dynamiske controls afvikles.Hvad er fidussen?
?:o) karsten_larsen
Her følger min demo kode:
' START CONTROL
Protected Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
If Page.IsPostBack = True Then
Session("Number") = 1
DesignShow(CType(Session("Number"), Integer))
End If
End Sub
' FORRIGE CONTROL
Protected Sub btnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click
If Page.IsPostBack = True Then
Dim a As Integer = 0
a = CType(Session("Number"), Integer)
a = a - 1
If a < 1 Then
a = 1
End If
Session("Number") = CType(a, String)
DesignShow(CType(Session("Number"), Integer))
End If
End Sub
' NAESTE CONTROL
Protected Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
If Page.IsPostBack = True Then
' Her skal værdier fanges fra netop afviklet dynamiske control
'?????????????????????????????????????????????????????????????
Dim a As Integer = 0
a = CType(Session("Number"), Integer)
a = a + 1
Session("Number") = CType(a, String)
DesignShow(CType(Session("Number"), Integer))
End If
End Sub
' AFVIKLING AF DYNAMISKE CONTROL
Sub DesignShow(ByVal Number As Integer)
Label1.Text = Number
Dim i As Integer = 0
If Number = 1 Then
DesignTextBox(1)
End If
If Number = 2 Then
DesignTextBox(1)
DesignTextBox(2)
End If
If Number = 3 Then
DesignRadioButtonList(1, 3)
End If
'etc
End Sub
' DESIGN AF CONTROL - TEXTBOX
Sub DesignTextBox(ByVal NumberId As Integer)
Dim t As New TextBox()
t.ID = "tb" & NumberId
Me.PlaceHolder1.Controls.Add(t)
End Sub
' DESIGN AF RADIOBUTTONLIST
Sub DesignRadioButtonList(ByVal NumberId As Integer, ByVal AntalValg As Integer)
Dim r As New RadioButtonList()
r.ID = "rbl" & NumberId
r.RepeatDirection = RepeatDirection.Horizontal
Dim i As Integer = 0
For i = 1 To AntalValg
r.Items.Add(New ListItem(AntalValg.ToString, i.ToString()))
Next
Me.PlaceHolder1.Controls.Add(r)
End Sub