no value selected from DropDownList
-
I have a dropdownlist with number which will show the number of text field with the number i selected. My code behind is as below but I found there is no selected value running in my code. Is my code correct? example if I select number 2 in my dropdownlist then the item in my placeHolder will show 2 times. ------------------------------------------------------------------------ Partial Class Admin_AddTest Inherits System.Web.UI.Page Dim value As Integer Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If User.Identity.IsAuthenticated = True Then LoadDisplay(value) Else Response.Redirect("default.aspx") End If End Sub Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged ' If Page.IsPostBack Then value = DropDownList1.SelectedItem.Value LoadDisplay(value) ' End If End Sub Private Sub LoadDisplay(ByVal intValue As Integer) Dim i As Integer Dim txtLabel1 As New Label Dim lblQues As New Label Dim lblAns As New Label For i = 0 To value 'display type of question txtLabel1.Text = "
Type of question
" plhHolder.Controls.Add(txtLabel1) Dim optMulChoice As New RadioButton() Dim optTrueFalse As New RadioButton() optMulChoice.Text = " Multiple Answer
" optMulChoice.GroupName = "MultipleAnswer" optMulChoice.ID = "rbtMulChoice" plhHolder.Controls.Add(txtLabel2) plhHolder.Controls.Add(optMulChoice) optTrueFalse.Text = " True/False" optTrueFalse.GroupName = "TrueFalse" optTrueFalse.ID = "rbtTrueFalse" plhHolder.Controls.Add(txtLabel3) plhHolder.Controls.Add(optTrueFalse) lblQues.Text = "
Question:
" plhHolder.Controls.Add(lblQues) Dim txtQues As New TextBox txtQues.ID = "txtQues" txtQues.TextMode = TextBoxMode.MultiLine plhHolder.Controls.Add(txtQues) lblAns.Text = "Answer:
" plhHolder.Controls.Add(lblAns) Dim optAnsA As New RadioButton() Dim optAnsB As New RadioButton() Dim optAnsC As New Rad -
I have a dropdownlist with number which will show the number of text field with the number i selected. My code behind is as below but I found there is no selected value running in my code. Is my code correct? example if I select number 2 in my dropdownlist then the item in my placeHolder will show 2 times. ------------------------------------------------------------------------ Partial Class Admin_AddTest Inherits System.Web.UI.Page Dim value As Integer Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If User.Identity.IsAuthenticated = True Then LoadDisplay(value) Else Response.Redirect("default.aspx") End If End Sub Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged ' If Page.IsPostBack Then value = DropDownList1.SelectedItem.Value LoadDisplay(value) ' End If End Sub Private Sub LoadDisplay(ByVal intValue As Integer) Dim i As Integer Dim txtLabel1 As New Label Dim lblQues As New Label Dim lblAns As New Label For i = 0 To value 'display type of question txtLabel1.Text = "
Type of question
" plhHolder.Controls.Add(txtLabel1) Dim optMulChoice As New RadioButton() Dim optTrueFalse As New RadioButton() optMulChoice.Text = " Multiple Answer
" optMulChoice.GroupName = "MultipleAnswer" optMulChoice.ID = "rbtMulChoice" plhHolder.Controls.Add(txtLabel2) plhHolder.Controls.Add(optMulChoice) optTrueFalse.Text = " True/False" optTrueFalse.GroupName = "TrueFalse" optTrueFalse.ID = "rbtTrueFalse" plhHolder.Controls.Add(txtLabel3) plhHolder.Controls.Add(optTrueFalse) lblQues.Text = "
Question:
" plhHolder.Controls.Add(lblQues) Dim txtQues As New TextBox txtQues.ID = "txtQues" txtQues.TextMode = TextBoxMode.MultiLine plhHolder.Controls.Add(txtQues) lblAns.Text = "Answer:
" plhHolder.Controls.Add(lblAns) Dim optAnsA As New RadioButton() Dim optAnsB As New RadioButton() Dim optAnsC As New RadIs any one can help? I am in urgent. I will like my item to repeat as the number that i have selected from drop downlist.