asp.net – 绑定ListView InsertItemTemplate中的DropDownList抛出错误
发布时间:2020-05-22 17:17:05 所属栏目:asp.Net 来源:互联网
导读:我有一个ListView绑定到 LinqDataSource并显示选定的位置.插入项包含一个下拉列表,该列表从另一个LinqDataSource拉出以提供所有未选择的位置. 问题是加载页面时出现以下错误: 数据绑定方法(如Eval(),XPath()和Bind())只能在数据绑定控件的上下文中使用. 我在
|
我有一个ListView绑定到 LinqDataSource并显示选定的位置.插入项包含一个下拉列表,该列表从另一个LinqDataSource拉出以提供所有未选择的位置. 问题是加载页面时出现以下错误: 数据绑定方法(如Eval(),XPath()和Bind())只能在数据绑定控件的上下文中使用. 我在网站的另一个页面上做了一个非常类似的设置,并没有给我们这个错误,所以我很困惑.我知道我可以通过不绑定,手动查找控件和获取值来解决这个问题,但这应该工作,我不明白为什么不是. 有什么想法吗? 源代码的更好部分如下. <asp:LinqDataSource ID="ldsLocations" runat="server"
ContextTypeName="ClearviewInterface.ESLinqDataContext" EnableDelete="true" EnableInsert="true"
OnInserting="ldsLocations_Inserting" OnDeleting="ldsLocations_Deleting"
TableName="crmLocations" OrderBy="addr1" OnSelecting="ldsLocations_Selecting" />
<asp:LinqDataSource ID="ldsFreeLocations" runat="server"
ContextTypeName="ClearviewInterface.ESLinqDataContext" OrderBy="addr1"
TableName="v_CVLocations" OnSelecting="ldsFreeLocations_Selecting" />
<asp:ListView ID="lvLocations" DataSourceID="ldsLocations" DataKeyNames="ID" InsertItemPosition="LastItem" runat="server" >
<InsertItemTemplate>
<tr>
<td colspan="6"><hr /></td>
</tr>
<tr>
<td colspan="2">
<asp:DropDownList ID="ddlFreeLocations" DataSourceID="ldsFreeLocations" DataTextField="addr1"
DataValueField="record" MarkFirstMatch="true" SelectedValue='<%# Bind("record") %>'
runat="server" />
</td>
<td><asp:ImageButton ID="btnAdd" CommandName="Insert" SkinID="Insert" runat="server" /></td>
</tr>
</InsertItemTemplate>
解决方法正如 Joteke’s Blog所解释的,这是一个引用的解决方案.
(编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 路径’PROPFIND’被禁止?
- asp.net-mvc – 从MVC Controller调用Web API来构建并传递模
- ASP到ASP.NET会话变量
- asp.net – 跟踪间歇性“对象引用未设置为对象的实例”.构建
- asp.net-mvc – 在部分视图中传递参数 – MVC3 / Razor
- ASP.NET C#5异步Web应用程序使用异步和等待
- 在ASP.NET Web API的JSON输出中没有时间的日期
- ASP.NET UpdatePanel和Javascript __dopostback
- 缩小ASP.NET应用程序的Html输出
- 实体框架 – MVC 3 EF 4.1 dbContext – 删除具有不可空的外
推荐文章
站长推荐
热点阅读
