I need to list table book in my views and when i click id_book a form is autoremplit with content like this.
First part
id book : input
name book : input
price : input
button (add)
and in the secon page of my view a table like that (with pagination)
id name price
1 book1 10
2 book2 20
, ,, ,
50 book50 50
page1,page 2,,,,,,,,,
my question how can manage this iin the same page.
which viewmodel could pass to my page
public class BookViewModel
{
public int Id { get; set; }
[Required(ErrorMessage = "Please provide a Title!")]
[StringLength(25, ErrorMessage = "title must be less than 25 characters!")]
[DisplayName("Title")]
public string Title{ get; set; }
[Required(ErrorMessage = "Please provide a Price!")]
[DisplayName("Price")]
public string Price{ get; set; }
}
but how to recup all books?(i think i cant just pass a viewmodel by View)
NoMoneyNojob
0 Points
19 Posts
list and forum to add and update in teh same view????
Aug 10, 2012 02:56 PM|LINK
Hi all,
I need to list table book in my views and when i click id_book a form is autoremplit with content like this.
First part
id book : input
name book : input
price : input
button (add)
and in the secon page of my view a table like that (with pagination)
id name price
1 book1 10
2 book2 20
, ,, ,
50 book50 50
page1,page 2,,,,,,,,,
my question how can manage this iin the same page.
which viewmodel could pass to my page
public class BookViewModel { public int Id { get; set; } [Required(ErrorMessage = "Please provide a Title!")] [StringLength(25, ErrorMessage = "title must be less than 25 characters!")] [DisplayName("Title")] public string Title{ get; set; } [Required(ErrorMessage = "Please provide a Price!")] [DisplayName("Price")] public string Price{ get; set; } }but how to recup all books?(i think i cant just pass a viewmodel by View)
any ideas??
CPrakash82
All-Star
18270 Points
2839 Posts
Re: list and forum to add and update in teh same view????
Aug 11, 2012 03:16 AM|LINK
Follow these steps.
Thanks
ignatandrei
All-Star
134945 Points
21625 Posts
Moderator
MVP
Re: list and forum to add and update in teh same view????
Aug 11, 2012 03:17 AM|LINK
1. add a List<book> to your ViewModel
http://msprogrammer.serviciipeweb.ro/2010/03/29/asp-net-mvc-orm-and-viewmodels/
2. See http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx