再次使用EntityDataSource问题进行数据绑定 [英] Databinding with EntityDataSource question again

查看:199
本文介绍了再次使用EntityDataSource问题进行数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我再次观察EntityDataSource控件的奇怪行为。

鉴于此EDM
公司 - 用户 - 城市 - 国家



公司 - 城市 - 国家

( - )这意味着通过导航属性进行关联

I am once again observing strange behaviour of EntityDataSource control.

Given this EDM
Company - Users - Cities - Country

and

Company - Cities - Country

(-) this means association through navigation property

EntityDataSource将使用此数据绑定语法加载和绑定国家/地区名称

<%
DataBinder .Eval(Container.DataItem, " Cities.Country.country_name" )%>

当Include如下并且数据绑定控件是DetailsView并且我绑定某个公司

1)Include =" Cities,Country"

但在另一种情况下,当数据绑定控件是FormView时,我绑定某个用户数据和城市和国家的相同数据绑定语法(上图),要求包括:

2)包含=" Company,Cities.Country"

这里发生了什么?



谢谢,最好的问候

EntityDataSource would load and bind Country name using this databinding syntax

<%
# DataBinder.Eval(Container.DataItem, "Cities.Country.country_name") %>

when Include is the following and the databinding control is DetailsView and I am binding a certain Company

1) Include="Cities, Country"

but in the other case when the databinding control is FormView, I am binding a certain User data and the same databinding syntax for City and Country (above), requires this Include:

2) Include="Company, Cities.Country"

What is going on here??


Thank you, best regards

推荐答案

Marko,

让我试着澄清一下:搜索结果1。 Eval()将导致控件和表达式所代表的值之间的数据绑定发生,但它不会"加载和绑定"。正如你所说。它是使用Include导致相关实体加载的原因。
2。您分配给Include属性的值实际上是来自根实体的导航属性的路径。根据您对模型的描述,我相信您必须在#1和#2示例中分配的值。

希望这有意义,
Diego
Marko,

Let me try to clarify:

1. Eval() will cause databinding between the control and the value represented by the expression to happen, but it won't "load and bind" as you say. It is the use of Include what causes the the related entities to be loaded.

2. The values you assign to the Include property are actually paths of navigation properties from the root entity. According to your description of the model, I believe the values you have to assign in your #1 and #2 examples are expected.

Hope this makes sense,
Diego


这篇关于再次使用EntityDataSource问题进行数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆