views:

22

answers:

1

Hi,

for any new report requirement -

1] We will copy existing page, change sql, add authorisation and Done. This activity doesn't take more than half an hour.

2] or add IF else block in the existing page.

However in MVC world, I have Controller Action - which will return model to view.

And in View - Result and Headers will be displayed using <% foreach (var item in Model) %>

Here I want a generic View which will display headers and results irrespective of number of columns in Model.

Any suggestions?

A: 

How about having the following model:

public class MyModel
{
    public IEnumerable<string> Headers { get; set; }
    public IEnumerable<string> Values { get; set; }
}

Then you could loop through the headers and values in your view to display them.

Darin Dimitrov
soory very basic question - How to add values into Headers and values into ths IEnumerable variable.
swapneel