Below code i have to ammend for adding a dropdown in my asp website. I have already added could you please check what is wrong.
Function collectEmailBodyText()
Try
Dim counterEnd As Integer = subActivated_HowManyControlsInAPanel()
Dim counter As Integer = 0
Dim tempPanelLabel As Label
Dim tempPanelInputBox As TextBox
Dim tempPanelDropDownBox As DropDownList
Dim tempCollector As String
Dim panelUsed As String = ""
'* Find out which panel is used to collect panel data:
panelUsed = view0_panelUsed.ToString
Response.Write("<!-- " + panelUsed + " -->")
'
tempCollector = "<p><b>" + lbl_viewTitle0.Text + "</b>"
tempCollector = tempCollector + "<br>" + lbl_view0_firstName.Text + ": " + txt_firstName.Text
tempCollector = tempCollector + "<br>" + lbl_view0_surname.Text + ": " + txtSurName.Text
tempCollector = tempCollector + "<br>" + lbl_view0_ContactNum.Text + ": " + txt_contactNum.Text
'
tempCollector = tempCollector + "<p><b>" + lbl_viewTitle1.Text + "</b>"
tempCollector = tempCollector + "<br>" + lbl_view1_firstName.Text + ": " + txt_view1_firstname.Text
tempCollector = tempCollector + "<br>" + lbl_view1_surname.Text + ": " + txt_view1_surname.Text
tempCollector = tempCollector + "<br>" + lbl_view1_userID.Text + " " + txt_view1_userID.Text
tempCollector = tempCollector + "<br>" + lbl_view1_workUnit.Text + ": " + ddl_view1_workunit.SelectedItem.Text + " :: " + ddl_view1_workunit.SelectedValue.ToString()
tempCollector = tempCollector + "<br>" + lbl_view0_typeOfRequest.Text + ": " + ddl_view0_typeOfRequest.SelectedItem.ToString
tempCollector = tempCollector + "<br>" + lbl_view0_workUnitLevel.Text + ": " + ddl_view0_workUnitLevel.SelectedItem.ToString + "<br>"
'
'* Collect panel data:
Do
counter = counter + 1
tempPanelLabel = New Label
tempPanelInputBox = New TextBox
tempPanelDropDownBox = New DropDownList
tempPanelLabel = form1.FindControl("lbl_" + panelUsed + "_label" + counter.ToString())
tempPanelInputBox = form1.FindControl("txt_" + panelUsed + "_input" + counter.ToString())
tempPanelDropDownBox = DirectCast(form1.FindControl(("txt_" & panelUsed & "_ddinput") + counter.ToString()), DropDownList)
tempCollector = tempCollector + "<br>" + tempPanelLabel.Text
'tempCollector = tempCollector + ": " + tempPanelInputBox.Text
tempCollector = tempCollector + ": " + tempPanelDropDownBox.SelectedValue
Loop Until counter = counterEnd
'
If storeSelected() = 0 Then
tempCollector = tempCollector + "<p><b>" + lbl_viewTitle2.Text + "</b>"
tempCollector = tempCollector + "<br>" + lbl_view2_ManagersEmailAddress.Text + ": " + txt_view2_ManagersEmailAddress.Text
End If
'
Return tempCollector
Catch ex As Exception
Return ex.ToString()
Response.Write(ex.ToString())
End Try
End Function
Below is the extra line i added
tempPanelDropDownBox = DirectCast(form1.FindControl(("txt_" & panelUsed & "_ddinput") + counter.ToString()), DropDownList)
and i am getting the following error:
System.NullReferenceException: Object reference not set to an instance of an object. at WebApplication1._Default.collectEmailBodyText() in C:\v1.5_production_05June09\Default.aspx.vb:line 220