HeadModel:
[KEY]
public int ID {get;set;}
public datetime dateins {get;set;}
public string note {get;set;}
public ICollection<RowModel> rows {get;set;}
and
RowModel
[KEY]
public int ID {get;set;}
public decimal qty {get;set;}
public decimal price {get;set;}
public string note {get;set;}
public HeadModel head {get;set;}
I would like to implement a page where i can create a new Head and add roows in it in the same page ...
If you want to do it client side, then it is only possible through JQuery. Otherwise you need to post the form every time to add a new row and then add new item in the list and pass it back to view and your for loop will take care of it for you.
ESA
0 Points
30 Posts
multi form to create new
Jul 03, 2012 10:50 AM|LINK
i've two class model:
HeadModel: [KEY] public int ID {get;set;} public datetime dateins {get;set;} public string note {get;set;} public ICollection<RowModel> rows {get;set;}and
RowModel [KEY] public int ID {get;set;} public decimal qty {get;set;} public decimal price {get;set;} public string note {get;set;} public HeadModel head {get;set;}I would like to implement a page where i can create a new Head and add roows in it in the same page ...
any help???
thanks a lot
Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: multi form to create new
Jul 03, 2012 12:27 PM|LINK
create a new Model
call EmpModel or depend on the task of the View
then
class EmpModel
{
public HeadModel Header {get;set;}
public RowModel Row {get;set;}
}
and return this to View and can access both models using Model.Header and using Model.Row
ESA
0 Points
30 Posts
Re: multi form to create new
Jul 03, 2012 01:40 PM|LINK
but i can have multi rows for 1 header ...
ignatandrei
All-Star
137696 Points
22154 Posts
Moderator
MVP
Re: multi form to create new
Jul 03, 2012 01:47 PM|LINK
please see
http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx
ESA
0 Points
30 Posts
Re: multi form to create new
Jul 03, 2012 04:11 PM|LINK
i like it ...
i use a table to elencate them ...
is it possible to add a new table row without jquery???
thanks a lot
CPrakash82
All-Star
18722 Points
2900 Posts
Re: multi form to create new
Jul 03, 2012 11:01 PM|LINK
If you want to do it client side, then it is only possible through JQuery. Otherwise you need to post the form every time to add a new row and then add new item in the list and pass it back to view and your for loop will take care of it for you.
Thanks,
Young Yang -...
All-Star
21741 Points
1825 Posts
Microsoft
Re: multi form to create new
Jul 04, 2012 02:05 AM|LINK
I don't think it is a good idea to add Head and Rows in the same page, I suggest you can use lazy loading, please refer to this tutorials: http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc
If you still want add these in one page, i think jquery is the best way.
Hope this helpful
Regards
Feedback to us
Develop and promote your apps in Windows Store
ignatandrei
All-Star
137696 Points
22154 Posts
Moderator
MVP
Re: multi form to create new
Jul 04, 2012 02:31 AM|LINK
Jquery is just a wrappper for javascript.
Without javascript, on client side, no.( see http://bit.ly/mvc_ajax_jquery for a demo).
On server side, you can post to an action and that action retutns a new table.
ESA
0 Points
30 Posts
Re: multi form to create new
Jul 04, 2012 07:15 AM|LINK
then if i use 2 pages:
1 to compile head and 1 to compile rows???
but how can i save head and rows in memory until the user click on save button??
ignatandrei
All-Star
137696 Points
22154 Posts
Moderator
MVP
Re: multi form to create new
Jul 04, 2012 07:19 AM|LINK
If you study the link, 2 pages are not necessary.
No need. Just POST to the action