Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. binding a textbox

binding a textbox

Scheduled Pinned Locked Moved Database
helpcsharpquestionasp-netdatabase
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 12287337
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups