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. Web Development
  3. ASP.NET
  4. A form for creating a one to many record in a db

A form for creating a one to many record in a db

Scheduled Pinned Locked Moved ASP.NET
questiondatabasewindows-admintutorial
3 Posts 2 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.
  • Q Offline
    Q Offline
    Quake2Player
    wrote on last edited by
    #1

    If I'm having a form with n textboxs (n defined by te user by pressing a "new registry" button for example), and the textboxs are named product1, product2, ...productn.. How should I retrieve the data in the POST? Should I send n thrue the form too? What is the typical way of doing this kind of forms??.. that there is a main record in a db (for example some headers) and n records within that record? is there a good practice way? The db would look like table1: mainid, headers table2: id, mainid, etc. (ie. one to many relationship)

    A 1 Reply Last reply
    0
    • Q Quake2Player

      If I'm having a form with n textboxs (n defined by te user by pressing a "new registry" button for example), and the textboxs are named product1, product2, ...productn.. How should I retrieve the data in the POST? Should I send n thrue the form too? What is the typical way of doing this kind of forms??.. that there is a main record in a db (for example some headers) and n records within that record? is there a good practice way? The db would look like table1: mainid, headers table2: id, mainid, etc. (ie. one to many relationship)

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Quake2Player wrote:

      If I'm having a form with n textboxs (n defined by te user by pressing a "new registry" button for example), and the textboxs are named product1, product2, ...productn..

      I guess you are creating dynamic textbox on Button Click. The control which you are creating dynamically, you need to created before Page_Load(), other wise, it will not able to maintain the View State Data or will not load the Postback Data. If you deeply look inside ASP.NET Page Life Cycle, Before Page_Load(), there are two different methods calls. 1) LoadViewState() and 2)LoadPostbackData(). So, if you create any control on Page_Load(), or after that it will not able to load the data. So you need to create such control either in Pre_Init() or Init() method.

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

      Q 1 Reply Last reply
      0
      • A Abhijit Jana

        Quake2Player wrote:

        If I'm having a form with n textboxs (n defined by te user by pressing a "new registry" button for example), and the textboxs are named product1, product2, ...productn..

        I guess you are creating dynamic textbox on Button Click. The control which you are creating dynamically, you need to created before Page_Load(), other wise, it will not able to maintain the View State Data or will not load the Postback Data. If you deeply look inside ASP.NET Page Life Cycle, Before Page_Load(), there are two different methods calls. 1) LoadViewState() and 2)LoadPostbackData(). So, if you create any control on Page_Load(), or after that it will not able to load the data. So you need to create such control either in Pre_Init() or Init() method.

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        Q Offline
        Q Offline
        Quake2Player
        wrote on last edited by
        #3

        That also applies for ASP.NET MVC? Which isnt that event oriented as pure ASP.net? Anyway, is it ok the way im describing? To retrieve "n" and based on that retrieve the inputs.. or is there something like a container where i can do like "for each control in container" ?

        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