Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
for example i have a dropdownlist having values 1,2,3 and a textbox having value 10,how do i subtract these values ie if choosen 1 then output should be 9.output could be shown in another textbox
Posted
Comments
What have you tried and where is the issue?

First, convert the textbox value to a number. That's easy, but since this is a textbox, you shoudl do it like this:
C#
int myValue;
if (!int.TryParse(myTextBox.Text, out myValue))
   {
   // Tell the user he didn't enter a number!
   ...
   return;
   }
// All ok - move on...

Then, do the same for your drop down list: that's even easier because you control the values:
C#
int myDDLValue = int.Parse(myDropDownList.Text);

Then just do it!
C#
myOutputTextBox.Text = (myDDLValue - myValue).ToString();
 
Share this answer
 
Comments
haunter_007 13-Apr-14 11:38am    
Thanks a lot that did it :D
OriginalGriff 13-Apr-14 12:09pm    
You're welcome!
This is basic programming that you should really understand before you start writing form based applications. See http://www.codeproject.com/Messages/4799340/Re-Csharp.aspx[^], while not exact, the principle is the same.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900