我是 vb9 和 .NET MVC 的新手。我想构建一个 MVC 辅助函数,我为其传递一个实体框架对象并让它构建一个选择。一般来说,我尝试过这样的事情:
Public Function RenderSelect(ByVal helper As HtmlHelper, ByVal sSelectName As String, ByVal aItmes As Array, Optional ByVal sTitleKeyName As String = "name", Optional ByVal sValueKeyName As String = "id") As String
' open select
For Each Object In aItmes
' here i would like to do something like:
Dim OptionValue = Object.(sValueKeyName)
' NOTE: I have a var with the property name
Dim OptionTitle = Object.(sTitleKeyName)
. then add the option structure to the select
Next
' close select
Return String
End Function
但是,它不起作用。有办法做到这一点并传递当前实体对象会很棒。数据类型打败了我。提前致谢。