我想要动态列表复选框。我列出了复选框,但未将值发布到控制器。
模型中的属性:
Public Property PaymentTypes() As IList(Of PayType)
Get
Return repRestaurant.GetAllPaymentTypes()
End Get
Set(ByVal value As IList(Of PayType))
_PaymentTypes = value
End Set
End Property
PayType:
Public Class PayType
Public Property PayTypeID As Integer
Public Property PaymentName As String
Public Property Checked As Boolean = False
End Class
查看:
@For i As Integer = 0 To Model.PaymentTypes.Count - 1
@Html.CheckBoxFor(Function(m) m.PaymentTypes(i).Checked)
Next
发布到操作后观看屏幕:
答案 0 :(得分:0)
问题出现在paytype属性集方法中。我更改了属性集和问题修复