Click here to Skip to main content
15,889,992 members
Home / Discussions / C#
   

C#

 
AnswerRe: SaveFileDialog PinPopular
OriginalGriff1-Feb-16 23:40
mveOriginalGriff1-Feb-16 23:40 
AnswerRe: SaveFileDialog Pin
BillWoodruff2-Feb-16 0:02
professionalBillWoodruff2-Feb-16 0:02 
AnswerRe: SaveFileDialog PinPopular
Dave Kreskowiak2-Feb-16 1:27
mveDave Kreskowiak2-Feb-16 1:27 
GeneralRe: SaveFileDialog Pin
BillWoodruff2-Feb-16 2:13
professionalBillWoodruff2-Feb-16 2:13 
GeneralRe: SaveFileDialog Pin
Dave Kreskowiak2-Feb-16 3:51
mveDave Kreskowiak2-Feb-16 3:51 
GeneralRe: SaveFileDialog Pin
John Torjo3-Feb-16 13:39
professionalJohn Torjo3-Feb-16 13:39 
AnswerRe: SaveFileDialog Pin
Kevin Marois3-Feb-16 11:35
professionalKevin Marois3-Feb-16 11:35 
QuestionTextbox help(edited) Pin
Member 122873371-Feb-16 20:25
Member 122873371-Feb-16 20:25 
C#
how are you all.
i am new to asp.net and c#. i need help.

well my question is, i have a textbox in which a user have to enter a float value in the webform.

and i want to manipulate that value in a calculation.
so have created a class for the calculation which is Sales class. in that class i have declared Price as a float value,the value which should be obtained from the textbox.ie public float Price {get;set;}

Now my problem is with binding/linking the Price variable with the textbox in the button_click method.

initially i had done it this way:

in my .aspx.cs file i have created an object of the class in this case :

Sales s = new Sales ();

protected void button_Click (object sender EventArgs e)

{
s.Price =Convert.ToInt32(Textbox1.Text);
s.Save();
}

i want the Price value to be saved in my database after a user clicks the SAVE button from the webform.

Now the problem is when i run the application there is an error (
Hide   Copy Code

An exception of type 'System.FormatException occur but was not handred in the mscorlib.dll but was not handled in the  user code

)
on the line :
s.Price = Convert.ToInt32(Textbox1.Text);

could i have done something wrong in the code?


modified 2-Feb-16 2:33am.

AnswerRe: Textbox help(edited) Pin
BillWoodruff1-Feb-16 20:55
professionalBillWoodruff1-Feb-16 20:55 
GeneralRe: Textbox help(edited) Pin
Member 122873372-Feb-16 8:58
Member 122873372-Feb-16 8:58 
AnswerRe: Textbox help(edited) Pin
OriginalGriff1-Feb-16 20:57
mveOriginalGriff1-Feb-16 20:57 
GeneralRe: Textbox help(edited) Pin
BillWoodruff1-Feb-16 21:06
professionalBillWoodruff1-Feb-16 21:06 
GeneralRe: Textbox help(edited) Pin
OriginalGriff1-Feb-16 21:36
mveOriginalGriff1-Feb-16 21:36 
GeneralRe: Textbox help(edited) Pin
BillWoodruff1-Feb-16 22:32
professionalBillWoodruff1-Feb-16 22:32 
GeneralRe: Textbox help(edited) Pin
Member 122873372-Feb-16 8:54
Member 122873372-Feb-16 8:54 
QuestionTextbox help Pin
Member 122873371-Feb-16 20:25
Member 122873371-Feb-16 20:25 
QuestionTextbox binding/ Pin
Member 122873371-Feb-16 20:24
Member 122873371-Feb-16 20:24 
Questiondoes MethodInvoker will not work on win XP? Pin
Gilbert Consellado1-Feb-16 18:09
professionalGilbert Consellado1-Feb-16 18:09 
AnswerRe: does MethodInvoker will not work on win XP? Pin
John Torjo1-Feb-16 22:57
professionalJohn Torjo1-Feb-16 22:57 
GeneralRe: does MethodInvoker will not work on win XP? Pin
Gilbert Consellado2-Feb-16 2:17
professionalGilbert Consellado2-Feb-16 2:17 
QuestionRe: does MethodInvoker will not work on win XP? Pin
Alan N1-Feb-16 23:09
Alan N1-Feb-16 23:09 
AnswerRe: does MethodInvoker will not work on win XP? Pin
Gilbert Consellado2-Feb-16 2:19
professionalGilbert Consellado2-Feb-16 2:19 
QuestionRetrieve a date from the result of a query in a variable c # Pin
Ibrahim.elh31-Jan-16 23:07
Ibrahim.elh31-Jan-16 23:07 
AnswerRe: Retrieve a date from the result of a query in a variable c # Pin
Sascha Lefèvre31-Jan-16 23:25
professionalSascha Lefèvre31-Jan-16 23:25 
GeneralRe: Retrieve a date from the result of a query in a variable c # Pin
Ibrahim.elh1-Feb-16 3:05
Ibrahim.elh1-Feb-16 3:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.