Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a customer entry form with save button.I want to do save the information of customer and want to show info in a grid in the same page. after saving this grid will auto refresh and load data. But could not implement the grid stuff in same view. So how can i use form and grid in same page??? Need help.
Posted
Comments
Jameel VM 16-Jul-13 1:01am    
Please post the code what you have tried

Create a ViewModel for example

C#
public class SampleViewModel
{
public int Id{get;set;}
public string Name{get;set;}

public List<customer> Customers{get;set;}
}</customer>

//Your loading index look like this
C#
public ActionResult Index()
{
List<customers> customers=//do the logic here for loading the collection you want;
var viewModel=new SampleViewModel();
viewModel.Customers=customers;
return View(viewModel);
}
//Create action when click save.
[HttpPost]
public ActionResult Create(SampleViewModel viewModel)
{
}</customers>


in the view return model as @model SampleViewModel

Hope this helps
 
Share this answer
 
Just do one thing in this code snippet
public ActionResult Index()
{
List<customers> customers=//do the logic here for loading the collection you want;
var viewModel=new SampleViewModel();
viewModel.Customers=customers;
return View(viewModel);
}
//Create action when click save.
[HttpPost]
public ActionResult Create(SampleViewModel viewModel)
{
List<customers> customers=//do the logic here for loading the collection you want;
var viewModel=new SampleViewModel();
viewModel.Customers=customers;
return View(viewModel);</customers>

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900