binding a textbox
-
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 (
An exception of type 'System.NullReferenceException' occurred in Version1.dll but was not handled in user code
) on the line : s.Price = Convert.ToInt32(Textbox1.Text); could i have done something wrong in the code?