tags:

views:

100

answers:

3

Hi Guys

I want to expose data to a view. Where the user select from (2006) to (2009)

The data will be

SupplierName,PlantName,2006,2007,2008,2009 data.

The user can also select from (2008) to (2009)

THhen the data will be SupplierName,PlantName,2008,2009

What will be the best way to create viewdata class for this?

+1  A: 

You need to look into AutoMapper! http://www.codeplex.com/AutoMapper This tool will help you to create ViewModels. You need a DTO (data transfer object) that holds all the classes and data that you need in your view.

Andrew Siemer
A: 

Have you had a look at the NerdDinner application and tutorial yet?

Robert Harvey
+1  A: 

The ViewData is easy, but it is more difficult to get the routing right:

public class ReportViewModel
{
  public string SupplierName{get;set;}
  public string PlantName{get;set;}
  public DateTime StartYear{get;set;}
  public DateTime EndYear{get;set;}
}

I would map the Supplier and Plant in the route and the filter year in the querystring.

If you do that, then you have to URL-encode the values AND get rid of forward slashes in the values.

Malcolm Frexner