私はvb9と.NETMVCを初めて使用します。EntityFrameworkオブジェクトを渡してselectをビルドさせる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
ただし、機能していません。これを実行して現在のエンティティオブジェクトを渡す方法があると便利です。データ型は私を打ち負かしています。前もって感謝します。