ListView 中的嵌套用户控件 (ListView) 未绑定

发布于 2024-10-28 09:56:20 字数 4460 浏览 2 评论 0原文

您好,我正在尝试在列表视图中实现嵌套用户控件,但用户控件未绑定。 这是我的代码。

<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>

``

我已经为这个问题苦苦挣扎了几天。 请帮忙!! 请帮忙!

Hi I am trying to implement a nested user control in listview and the user control doesn't get bound.
Here is my code.

<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>

``

I have been struggling with this problem for a few days now.
Please help!!
Please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨落星ぅ辰 2024-11-04 09:56:20

如果我查看您的代码,在我看来,您实际上并未将绑定分配给任何内容:

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

尝试改为

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

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

if I look at your code, it seems to me that you aren't actually assigning the binding to anything:

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

try instead

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

EDIT: in order to achieve two way data binding, one has to add BindableAttribute to the property on User Control

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文