ListView中的嵌套用户控件(ListView)不受约束

时间:2011-04-02 01:03:54

标签: asp.net listview controls nested

您好我正在尝试在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">
        &nbsp;<asp:Label ID="TaskIDLabel" runat="server" Text='<%# Eval("TaskID") %>' />
        &nbsp;<asp:Label ID="TaskLabel" runat="server" Text='<%# Eval("Task") %>' />
        &nbsp;<asp:Label ID="CreatedDateLabel" runat="server" Text='<%# Eval("CreatedDate") %>' />
        &nbsp;<asp:Label ID="UpdatedDateLabel" runat="server" Text='<%# Eval("UpdatedDate") %>' />
        &nbsp;<asp:Label ID="TimestampLabel" runat="server" Text='<%# Eval("Timestamp") %>' />
        &nbsp;<asp:Label ID="TaskTypeIDLabel" runat="server" Text='<%# Eval("TaskTypeID") %>' />
        &nbsp;<asp:Label ID="ProjectTaskStatusIDLabel" runat="server" Text='<%# Eval("ProjectTaskStatusID") %>' />
        &nbsp;<asp:Label ID="SystemObjectIDLabel" runat="server" Text='<%# Eval("SystemObjectID") %>' />
        &nbsp;<asp:Label ID="SystemObjectRecordIDLabel" runat="server" Text='<%# Eval("SystemObjectRecordID") %>' />
        &nbsp;<asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%# Eval("Active") %>' Enabled="false" />
        &nbsp;<asp:Label ID="CreatedByAccountIDLabel" runat="server" Text='<%# Eval("CreatedByAccountID") %>' />
        &nbsp;<asp:Label ID="UpdatedByAccountIDLabel" runat="server" Text='<%# Eval("UpdatedByAccountID") %>' />
        &nbsp;<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">
        &nbsp;<asp:Label ID="TaskIDLabel" runat="server" Text='<%# Eval("TaskID") %>' />
        &nbsp;<asp:Label ID="TaskLabel" runat="server" Text='<%# Eval("Task") %>' />
        &nbsp;<asp:Label ID="CreatedDateLabel" runat="server" 
            Text='<%# Eval("CreatedDate") %>' />
        &nbsp;<asp:Label ID="UpdatedDateLabel" runat="server" 
            Text='<%# Eval("UpdatedDate") %>' />
        &nbsp;<asp:Label ID="TimestampLabel" runat="server" 
            Text='<%# Eval("Timestamp") %>' />
        &nbsp;<asp:Label ID="TaskTypeIDLabel" runat="server" 
            Text='<%# Eval("TaskTypeID") %>' />
        &nbsp;<asp:Label ID="ProjectTaskStatusIDLabel" runat="server" 
            Text='<%# Eval("ProjectTaskStatusID") %>' />
        &nbsp;<asp:Label ID="SystemObjectIDLabel" runat="server" 
            Text='<%# Eval("SystemObjectID") %>' />
        &nbsp;<asp:Label ID="SystemObjectRecordIDLabel" runat="server" 
            Text='<%# Eval("SystemObjectRecordID") %>' />
        &nbsp;<asp:CheckBox ID="ActiveCheckBox" runat="server" 
            Checked='<%# Eval("Active") %>' Enabled="false" />
        &nbsp;<asp:Label ID="CreatedByAccountIDLabel" runat="server" 
            Text='<%# Eval("CreatedByAccountID") %>' />
        &nbsp;<asp:Label ID="UpdatedByAccountIDLabel" runat="server" 
            Text='<%# Eval("UpdatedByAccountID") %>' />
        &nbsp;<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>

``

我几天来一直在努力解决这个问题。 请帮忙!! 请帮忙!

1 个答案:

答案 0 :(得分:0)

如果我查看你的代码,在我看来你实际上并没有将绑定分配给任何东西:

<Enet:Comments ID="Comments1" runat="server" systemObjectID='8' '<%# Eval("TaskID") %>' />

尝试改为

<Enet:Comments ID="Comments1" runat="server" systemObjectID='8' YourProperty='<%# Eval("TaskID") %>' />

编辑:为了实现双向数据绑定,必须将BindableAttribute添加到用户控件上的属性