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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:38:33+00:00 2026-05-22T19:38:33+00:00

I have a dropdownlist (with values ‘CMC’ & ‘CHF’)and two textbox’s. when i select

  • 0

I have a dropdownlist (with values ‘CMC’ & ‘CHF’)and two textbox’s.
when i select an option from dropdownlist, a text box control appears (visibility is written in javascript).
when i enter a number into this textbox and hit the sumbit/next button it should save this information in database.
The logic works for the one option but its not working for the other!
Both the options have textbox’s assoicated with them, which are visible only when the respective option is selected.
the frontend logic works (i.e. the visibility) but when I enter a number for ‘txt_HFMN’ ( the option for this text box to appear
in the dropdown is ‘CHF’ and ‘CMC’ for textbox ‘txt_HFNumber’)

Here is the code in .cs file:

   if (txt_HFNumber != null)
    {

        strHFNUM = txt_HFNumber.Text;

    }
    else if (txt_HFMN != null)
    {
        strHFNUM = txt_HFMN.Text;

    }
    else
    {
        strHFNUM = string.Empty;
    }

I tried to debug it, to pin point the error. The above condition checks only for the ‘txt_HFNumber’, it never
checks the ‘else if’ part. even though I have entered a value in ‘txt_HFMN’ it checks for ‘txt_HFNumber’ and since
‘txt_HFNumber’ doesn’t exist in the front end/no value is entered in this textbox , it inserts a ‘null’ into the
database instead of ‘txt_HFMN’ entered value!

Advise.

Really appreciate your help.

  • 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-22T19:38:33+00:00Added an answer on May 22, 2026 at 7:38 pm

    I think you might want something a bit more like this, you’re checking to see if the textbox itself exists:

    if (!string.IsNullOrEmpty(txt_HFNumber.Text) ) 
       {        strHFNUM = txt_HFNumber.Text;    } 
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have dropdownlist with the values: <select id=myddl name=myddl> <option value=1>One</option> <option value=2>Twooo</option> <option
I have a dropdownlist with values -1,1,2 and text A,B,C i wanna set B
On my page I have a DropDownList which I populate with database values from
I have a DropDownList with values that I get from a SQL database. Depending
I have a dropdownlist in a page. The values of all the list items
I have DropDownList with CascadingDropDown extender. If I want to retrieve data from the
I have a DropDownList and a TextBox on a Page. When the user chooses
I have a dropdownlist and a textbox with a button on a form. When
I have a WebForms page that has two DropDownList controls on it that both
I have a dropdown box in my view which is populated with objects from

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.