I have a page which contains a 1 Form (for table 1) and a Telerik Data-Grid (table 2) , table 1 id has a relation in each table 2 data added. Lets say form 1 contains a field for Name and the telerik-grid contains Telephone No., it could be multiple so in
the grid i have a CRUD( pointed to table 2),. and in overall i have a save button.
my question is, how will i know that this table 2 data is for table 1( which is just im about to create when i press the save button),
this is really giving me a hard time. i was hoping for your immediate response to this issue, i don't have much time. T_T
I'm not 100% sure on what your question is so show an example if you can. If you're wanting to only submit one set of the fields, move the unwanted fields outside of your form. There are other ways to bind multiple models as well and display/gather on the
form too. One way is creating your own elements and not using HtmlHelpers and specifying a specific name tag. When the form posts, your controller will try to match that name with a property in your Controller arguments or properties in a class.
It sounds like you need a view model, take a look at this page (it's old but the concept it still the same).
Essentially you create a class that has properties for both of your models , then bind the page to this class. You can access both models now int the View.
onepercent
Member
11 Points
21 Posts
2 Models ,One Page
Nov 15, 2012 01:20 PM|LINK
Hi Guys,
I have a page which contains a 1 Form (for table 1) and a Telerik Data-Grid (table 2) , table 1 id has a relation in each table 2 data added. Lets say form 1 contains a field for Name and the telerik-grid contains Telephone No., it could be multiple so in the grid i have a CRUD( pointed to table 2),. and in overall i have a save button.
my question is, how will i know that this table 2 data is for table 1( which is just im about to create when i press the save button),
this is really giving me a hard time. i was hoping for your immediate response to this issue, i don't have much time. T_T
Thank You so much.^^
medelbrock
Member
729 Points
153 Posts
Re: 2 Models ,One Page
Nov 15, 2012 06:33 PM|LINK
I'm not 100% sure on what your question is so show an example if you can. If you're wanting to only submit one set of the fields, move the unwanted fields outside of your form. There are other ways to bind multiple models as well and display/gather on the form too. One way is creating your own elements and not using HtmlHelpers and specifying a specific name tag. When the form posts, your controller will try to match that name with a property in your Controller arguments or properties in a class.
CodeHobo
All-Star
18669 Points
2648 Posts
Re: 2 Models ,One Page
Nov 15, 2012 06:36 PM|LINK
It sounds like you need a view model, take a look at this page (it's old but the concept it still the same).
Essentially you create a class that has properties for both of your models , then bind the page to this class. You can access both models now int the View.
http://stephenwalther.com/archive/2009/04/13/asp-net-mvc-tip-50-ndash-create-view-models.aspx
Blog | Twitter : @Hattan