Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 230779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:52:41+00:00 2026-05-11T19:52:41+00:00

Below code i have to ammend for adding a dropdown in my asp website.

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:52:41+00:00Added an answer on May 11, 2026 at 7:52 pm

    It would be easier to know which object is null given line numbers, but at a guess one of the lines in the form

    tempPanelInputBox = form1.FindControl("txt_" + panelUsed + "_input" + counter.ToString())
    

    is failing, this would be because the name generated by the part “txt_” + panelUsed + “_input” + counter.ToString() doesn’t match a control within the form.

    So, look at the line 220 within the file, and check the control that it is looking for appears within the form.

    After looking at it, I think the line

    tempPanelDropDownBox = DirectCast(form1.FindControl(("txt_" & panelUsed & "_ddinput") + counter.ToString()), DropDownList)
    

    should read

    tempPanelDropDownBox = DirectCast(form1.FindControl(("txt_" & panelUsed & "_ddlinput") + counter.ToString()), DropDownList)
    

    the difference being ddl in the name not dd (Based on assumption that you name drop downs ddl)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In Visual Studio and most other half decent IDEs you… May 12, 2026 at 12:44 am
  • Editorial Team
    Editorial Team added an answer In general, you can't assume anything about the client. If… May 12, 2026 at 12:44 am
  • Editorial Team
    Editorial Team added an answer Found it just now (happy!) Dokan May 12, 2026 at 12:44 am

Related Questions

I am doing some performance tests using .Net 3.5 against SQL Server. I am
I have some simple code in which the main Thread is creating a new
Okay so I have a scenario similar to the below code, I have a
Below is a heavily cut down version of some code I have public class

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.