このような DefaultModelBinder を継承するカスタム モデル バインダーがあります。
Public Class GridFormBinder : Inherits DefaultModelBinder
Public Overrides Function BindModel(controllerContext As System.Web.Mvc.ControllerContext, bindingContext As System.Web.Mvc.ModelBindingContext) As Object
Dim result As Object = MyBase.BindModel(controllerContext, bindingContext)
'Code to handle special case for grid/List binding.
Return result
End Function
End Class
このカスタム バインダーを使用する理由は、(devexpress mvc gridview を使用して) グリッド内にさまざまな項目のリストを表示し、グリッド内のコントロールを項目のリストにバインドするためです。
BusinessCollectionBase (非常に変更された CSLA フレームワーク クラス) から派生したクラスを使用すると、すべてが思いどおりに機能します。BusinessCollectionBase は次のようなクラスから派生します...
<Serializable()> Public MustInherit Class BindableCollectionBase(Of T As IBusinessData)
Inherits CollectionBase
Implements IBindingList
Implements System.Collections.Generic.IEnumerable(Of T)
しかし、たとえば、から継承するクラスにバインドすると、BindingList<Customer>
常にMyBase.BindModel(controllerContext, bindingContext)
何も返されません。さまざまな汎用および非汎用の BCL コレクションを試しましたが、BindModel メソッドは常に null を返します。
DefaultModelBinder が通常のコレクションのモデルを作成して返すために必要なことはありますか?