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 203517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:23:09+00:00 2026-05-11T17:23:09+00:00

I have a ASP.NET webform that, aside from other controls, has a textbox for

  • 0

I have a ASP.NET webform that, aside from other controls, has a textbox for entering a value, a textbox to display values, a dropdownlistbox, and a search button. I am using the following code to display search results:

if (TextBox3.text == DropDownList3.Items.FindByText(TextBox3.Text).Value) 
{
  etc... 
}

The DDL3 gets its values from a DataTable, and the value entered into TextBox3 should match one of the DDL3 values to display the search results after the search button is clicked. The NullReferenceException error occurs when the TextBox3 value is either null or does not match any value in DDL3. This is reasonable; however, I have spent a few hours trying to handle this error and I cannot seem to figure out how to go about it. I have tried to add additional “If” statements, such as “if TextBox3 == null, etc…; however, to no avail. How should I change the above if statement to compensate for a null value or a wrong value?

Thank you,

DFM

  • 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-11T17:23:09+00:00Added an answer on May 11, 2026 at 5:23 pm

    Try using a try…catch on that exception:

    try {
        TextBox3.text = DropDownList3.Items.FindByText(TextBox3.Text).Value
    } catch (NullReferenceException ex) {
        TextBox3.text = "(none)";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET webform that has a listbox ( lbxRegions ) with multi-select
Within an asp.net webform I have some jquery that controls the positioning of elements
On my C# asp.net webform I have a search page that has roughly 20
I have a VS2010 ASP.Net webform that contains a GridView. This GridView has ShowHeaderWhenEmpty=True
I have a basic asp.net webform that handles events via standard postback. On this
Good Morning, I have created an ASP.NET 3.5 webform that allows users to search
within an asp.net webform project I have a session variable that I am populating
The situation I have an ASP.NET Webform that contains some status information about a
I have a RequiredFieldValidator with Display=Dynamic on my ASP.NET WebForm. I have assigned it
I have a simple Asp.NET webform with a TextBox. I have attached an AjaxControlToolkit

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.