简体   繁体   English

DataBinder.Eval问题

[英]DataBinder.Eval Issue

I have a some controls inside an EditItemTemplate within a RadListView control: 我在RadListView控件的EditItemTemplate中有RadListView控件:

 <telerik:RadComboBox ID="cbCategoryTypeTueET" runat="server" Skin="Office2010Black"
     SelectedValue='<%# DataBinder.Eval(Container.DataItem, "CategoryTypeID") %>'
     TabIndex="1" Width="100%" EmptyMessage="--Select Category Type--" DataSourceID="edsCatTypeTueET"
     DataTextField="CategoryName" DataValueField="CategoryTypeID" AutoPostBack="True"
     OnSelectedIndexChanged="cbCategoryTypeTueET_SelectedIndexChanged" AccessKey="t" AppendDataBoundItems="True">
</telerik:RadComboBox>
<asp:EntityDataSource ID="edsCatTypeTueET" runat="server" ConnectionString=""
     DefaultContainerName="ATITimeEntry" EnableFlattening="False" EntitySetName="TimeTrackingCategoryTypes"
     Select="it.[CategoryTypeID], it.[CategoryName]"
     Where="it.deletedFlag = false AND it.activeFlag = true" >
</asp:EntityDataSource>

The Entity datasource does have a connection string - I am using a new code generation template - so this is not an issue. 实体数据源确实具有连接字符串-我正在使用新的代码生成模板-因此这不是问题。

My problem is I want the combobox to bind on edit. 我的问题是我希望组合框在编辑时绑定。 But if activeFlag is false or deletedFlag is true (or both) the Radlistview will not go into edit mode. 但是,如果activeFlagfalsedeletedFlagtrue (或两者均为),则Radlistview将不会进入编辑模式。 Is there an elegant way to do this with markup or some elegant query? 有没有一种优雅的方法可以通过标记或一些优雅的查询来做到这一点?

My understandig is, you want to forbid edit on some conditions. 我的理解是,您想在某些情况下禁止编辑。

You have to subscripe the ItemDataBound Event from the RadListView. 您必须从RadListView订阅ItemDataBound事件。 There you can cast DataItem to your object and check the condition ( Get Data being bound to ListView ). 在那里,您可以将DataItem强制转换为对象并检查条件(将数据绑定到ListView )。

Then you can access your controls and manipulate them (like hide them)... Conditionaly disable command button 然后,您可以访问您的控件并进行操作(例如隐藏它们)... 有条件地禁用命令按钮

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM