1

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?

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.