您好我正在尝试在listview中实现嵌套用户控件,并且用户控件不受约束。 这是我的代码。
<asp:ListView ID="ListViewTaskList" runat="server" DataKeyNames="TaskID"
DataSourceID="SqlDataSourceTaskList" OnItemDataBound="ListViewTaskListItemDataBound" ItemPlaceholderID="itemPlaceholder">
<LayoutTemplate>
<div class="ListView ">
<div style="font-size:2em;color:#555555;margin-bottom:20px;">Task List</div>
<div ID="itemPlaceholder" runat="server">
</div>
</div>
</LayoutTemplate>
<ItemTemplate>
<div class="rlvI">
<asp:Label ID="TaskIDLabel" runat="server" Text='<%# Eval("TaskID") %>' />
<asp:Label ID="TaskLabel" runat="server" Text='<%# Eval("Task") %>' />
<asp:Label ID="CreatedDateLabel" runat="server" Text='<%# Eval("CreatedDate") %>' />
<asp:Label ID="UpdatedDateLabel" runat="server" Text='<%# Eval("UpdatedDate") %>' />
<asp:Label ID="TimestampLabel" runat="server" Text='<%# Eval("Timestamp") %>' />
<asp:Label ID="TaskTypeIDLabel" runat="server" Text='<%# Eval("TaskTypeID") %>' />
<asp:Label ID="ProjectTaskStatusIDLabel" runat="server" Text='<%# Eval("ProjectTaskStatusID") %>' />
<asp:Label ID="SystemObjectIDLabel" runat="server" Text='<%# Eval("SystemObjectID") %>' />
<asp:Label ID="SystemObjectRecordIDLabel" runat="server" Text='<%# Eval("SystemObjectRecordID") %>' />
<asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%# Eval("Active") %>' Enabled="false" />
<asp:Label ID="CreatedByAccountIDLabel" runat="server" Text='<%# Eval("CreatedByAccountID") %>' />
<asp:Label ID="UpdatedByAccountIDLabel" runat="server" Text='<%# Eval("UpdatedByAccountID") %>' />
<asp:Button ID="SelectButton" runat="server" CausesValidation="False" CommandName="Select" CssClass="rlvBSel" Text=" " ToolTip="Select" />
<div>
<Enet:Comments ID="Comments1" runat="server" systemObjectID='8' systemObjectRecordID="Comments1Init" />
</div>
</div>
</ItemTemplate>
<AlternatingItemTemplate>
<div class="rlvA">
<asp:Label ID="TaskIDLabel" runat="server" Text='<%# Eval("TaskID") %>' />
<asp:Label ID="TaskLabel" runat="server" Text='<%# Eval("Task") %>' />
<asp:Label ID="CreatedDateLabel" runat="server"
Text='<%# Eval("CreatedDate") %>' />
<asp:Label ID="UpdatedDateLabel" runat="server"
Text='<%# Eval("UpdatedDate") %>' />
<asp:Label ID="TimestampLabel" runat="server"
Text='<%# Eval("Timestamp") %>' />
<asp:Label ID="TaskTypeIDLabel" runat="server"
Text='<%# Eval("TaskTypeID") %>' />
<asp:Label ID="ProjectTaskStatusIDLabel" runat="server"
Text='<%# Eval("ProjectTaskStatusID") %>' />
<asp:Label ID="SystemObjectIDLabel" runat="server"
Text='<%# Eval("SystemObjectID") %>' />
<asp:Label ID="SystemObjectRecordIDLabel" runat="server"
Text='<%# Eval("SystemObjectRecordID") %>' />
<asp:CheckBox ID="ActiveCheckBox" runat="server"
Checked='<%# Eval("Active") %>' Enabled="false" />
<asp:Label ID="CreatedByAccountIDLabel" runat="server"
Text='<%# Eval("CreatedByAccountID") %>' />
<asp:Label ID="UpdatedByAccountIDLabel" runat="server"
Text='<%# Eval("UpdatedByAccountID") %>' />
<asp:Button ID="SelectButton" runat="server" CausesValidation="False"
CommandName="Select" CssClass="rlvBSel" Text=" " ToolTip="Select" />
<div>
<Enet:Comments ID="Comments1" runat="server" systemObjectID='8' '<%# Eval("TaskID") %>' />
</div>
</div>
</AlternatingItemTemplate>
``
我几天来一直在努力解决这个问题。 请帮忙!! 请帮忙!
答案 0 :(得分:0)
如果我查看你的代码,在我看来你实际上并没有将绑定分配给任何东西:
<Enet:Comments ID="Comments1" runat="server" systemObjectID='8' '<%# Eval("TaskID") %>' />
尝试改为
<Enet:Comments ID="Comments1" runat="server" systemObjectID='8' YourProperty='<%# Eval("TaskID") %>' />
编辑:为了实现双向数据绑定,必须将BindableAttribute添加到用户控件上的属性