1) User indicates in the UI what results the user wishes to see
2) The Controller interprets this and stores this for later
3) The Controller goes to the DAL and gets the data from the DAL
4) The Controller then modifies the return result somehow according to #2
5) The Controller then passes the modified data to the UI
6) The UI renders the data
I think your disconnect starts at 4 and may extend as far as 6.
The fact is that there are literally thousands of ways to do this. Here's one way to do it in amazingly C#-like pseudocode.
First, I'd create a view model that contains information on what I want to display to the user.
Original Linq to Sql (abbreviated):
public class Person
{
public string FirstName {get;set;}
public string LastName {get;set;}
public string Tel {get;set;}
}
My view model:
public partial class PeopleView
{
public bool ShowFirstName {get;set;}
public bool ShowLastName {get;set;}
public bool ShowTel {get;set;}
public IEnumerable<Person> People {get;set;}
}
The controller method that preps the model:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult PersonDetails(bool showFirstName,
bool showLastName, bool showTel)
{
var viewData = new PeopleView()
{
ShowFirstName = showFirstname,
ShowLastName = showLastName,
ShowTel = showTel,
People = Dal.GetPeople()
};
return View(viewData);
}
And here's the View:
<% foreach(var item in ViewData.Model.People){ %>
<% if(ViewData.Model.ShowFirstName) {%>
<%= item.FirstName %><br/>
<% } %>
<% if(ViewData.Model.ShowLastName) {%>
<%= item.LasttName %><br/>
<% } %>
<% if(ViewData.Model.ShowTel) {%>
<%= item.Tel %><br/>
<% } %>
<% } %>