MVC Reporting - a generic View which will display headers and results irrespective of number of columns in Model
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 displ开发者_运维百科ay headers and results irrespective of number of columns in Model.
Any suggestions?
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.
精彩评论