실제로 내부 데이터 소스를 별도로 만들었지 만 또 다른 문제가 있습니다. 부모의 엔터티 ID에 Where 절을 설정할 수 없습니다.
FormView.DataItem에 액세스 할 수 없습니다. 그것은 EntityDataSourceWrapper 타입이며 그것은 친구 클래스이고 접근 할 수 없습니다.
그래서 리플렉션을 통해이를 처리하는 함수를 만들었습니다.
Microsoft 버그라고 생각합니다. 문제가 해결 될 때까지 다음은 중첩 된 EntityDataSource 컨트롤을 사용하는 모든 사용자에게 유용 할 수 있습니다.
는 여기있다 :
Module Functions
Public Function GetEntity(Of TEntity As EntityObject)(ByVal entityDataSourceWrapper As Object) As TEntity
If entityDataSourceWrapper Is Nothing Then Return Nothing
Dim type = entityDataSourceWrapper.GetType()
If Not type.FullName = "System.Web.UI.WebControls.EntityDataSourceWrapper" Then Return Nothing
Dim wrapper = type.GetProperty("WrappedEntity", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)
Return DirectCast(wrapper.GetValue(entityDataSourceWrapper, Nothing), TEntity)
End Function
End Module
를 이제 코드에서 다음 작업을 수행 할 뒤에 :
Protected Sub fvAccounts_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles fvAccounts.DataBound
If fvAccounts.CurrentMode <> FormViewMode.ReadOnly Then Exit Sub
Dim account As Account = GetEntity(Of Account)(fvAccounts.DataItem)
If account Is Nothing Then Exit Sub
Dim edsReports As EntityDataSource = fvAccounts.Row.FindControl("edsReports")
edsReports.Where = "it.Account.AccountId = " & account.AccountId
gvReports.DataBind()
End Sub
참고 모델의 계층 구조 : 계정 많은보고가있다.