Implementing a dynamic drop down list box in a web form control in C#

Posted on 2004-11-26
Medium Priority
Last Modified: 2008-02-26
Dear Expert,
   I am developing a web form in C# which has a drop down list box that contains units of measure, i.e. in, ft, mm, m, and km. I have set the selected value to inch. Here is the scenario. Say the end user enters a value of 10 inside the corresponding text box. When the end user changes units to any other unit like mm the conversion works fine, showing the value 254 mm. How do I make this flexible so that if the end user decides to select a unit of measure for example mm, but doesn't want the converted mm value, which in this case is 10 inches, instead the end user wants to override the converted value  25 mm by changing the textbox value. If the end user wants to convert this newly entered value to say meters, it should just be a matter of selecting that from the drop down list box and displaying the value .025 m.
  I guess my question would be how do I keep track of the previous selected value at the same time keeping track of the newly selected value to provide for the correct conversion.


Question by:Khopkins32
  • 2
LVL 53

Accepted Solution

COBOLdinosaur earned 2000 total points
ID: 12682477
Just keep the last selectedIndex in a hidden input.  Then pass the old value from the hidden field and the new index value to the calculation function:

<input type="hidden" name="last" value="0">
<input type="text" name="Userin">


Author Comment

ID: 12683232
Thanks vervy much Coboldinosaur
LVL 53

Expert Comment

ID: 12683483
Glad I could help.  Thanks for the A. :^)


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question