[英]Entity Framework best practices drop-down list binding
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.
在ASP.NET MVC应用程序中,我正在编写作为搜索面板的部分控件。 Now this panel has
现在这个面板有
I have defined a View model as follows 我定义了一个View模型,如下所示
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? 是否直接或通过存储过程使用ado.net实体?
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 eg something like: 在视图(cshtml文件)上,如何使用这些属性与下拉列表或表格进行绑定,例如:
In short what is the best approach to go about it? 简而言之,最好的方法是什么?
Here is a picture to clarify 这是一张要澄清的图片
我正在使用bootstrap-multiselect自定义控件,但仍然想知道它是否能够在其中添加详细信息/相邻列
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.