It's going to be a long one so apologies in advance. In an ASP.NET MVC application I am writing a partial control that is a search panel. Now this panel has
- classes selection drop-down but with table instead of list (table has a checkbox, and two columns with group headers - classname and no.of students)
- year selection as dropdownlist (hopefully the easiest of all)
- Indicators list with checkboxes and group headers
I have defined a View model as follows
public class SearchControlModel
{
public List<Class> Classes {get; set;}
public List<Year> Years { get; set; }
public List<Indicator> Indicators { get; set; }
}
Where my entities are:
public class Class
{
public int classID { get; set; }
public Nullable<int> grade { get; set; }
public string classname { get; set; }
public virtual ICollection<Student> Students { get; set; }
}
public class Indicator
{
public int IndicatorID { get; set; }
public string IndicatorDescription { get; set; }
public virtual ICollection<Student> Students { get; set; }
}
My questions are:
What would be the right controls to display class and indicators (grid/table that appears as a drop-down)
Do I use the ado.net entities directly or through stored procedures?
If I use stored procedures, I will have to define a different entity that has only the specific properties that the stored procedure is dealing with or is there another way?
On the View (cshtml file) how do I use these properties to bind with drop-down or table e.g. something like:
- @Html.LabelFor(m => m.Classes)
- @Html.DropDownListFor(m => m.Classes, new { @class = "form-control" })
In short what is the best approach to go about it?
Here is a picture to clarify