0
我正在用MVC4和VBNet使用實體框架編寫應用程序。我有兩個型號,Printer.vb和Request.vb如何創建自定義編輯視圖MVC?
他們是如下圖所示,
Request.vb
Public Class Request
Public Property ID() As Integer
Public Property User() As String
Public Property Printer() As Printer
Public Property Approval() As Boolean
End Class
Public Class RequestDBContext
Inherits DbContext
Public Property Requests() As DbSet(Of Request)
End Class
Printer.vb
Public Class Printer
Public Property ID() As Integer
Public Property Name() As String
End Class
Public Class PrinterDBContext
Inherits DbContext
Public Property Printers() As DbSet(Of Printer)
End Class
我有創建引用數據庫中存在的打印機模型的請求時遇到問題。
我的要求視圖看起來像這樣,
<div class="editor-field">
@Html.EditorFor(Function(model) model.User)
@Html.EditorFor(Function(model) model.Approval)
@Html.EditorFor(Function(model) model.Printer)
@Html.ValidationMessageFor(Function(model) model.User)
</div>
但是`Model.EditorFor(model.Printer)不會創建任何東西。
如何向請求視圖添加一個字段,該字段將查找打印機並在該請求中引用它?
可以爲打印機添加編輯模板 –