A form for creating a one to many record in a db
-
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)
-
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)
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 onPage_Load()
, or after that it will not able to load the data. So you need to create such control either inPre_Init()
orInit()
method.Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
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 onPage_Load()
, or after that it will not able to load the data. So you need to create such control either inPre_Init()
orInit()
method.Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.