【问题标题】:PlaceHolder using Listview ErrorPlaceHolder 使用 Listview 错误
【发布时间】:2012-06-14 16:09:58
【问题描述】:

下面是我的标记代码,在编译时给了我错误消息。我在谷歌搜索了几个小时,但无法帮助自己。我的标记中不正确的代码是什么。 我有一个用于此页面的 cs 文件,它将数据绑定到此列表视图控件

任何解决此问题的帮助都会非常有帮助

错误消息:必须在 ListView 'listview1' 上指定项目占位符。通过将控件的 ID 属性设置为“itemContainer”来指定项目占位符。项目占位符控件还必须指定 runat="server"。

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Attestation2.aspx.cs" Inherits="Attestation2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body style="z-index: 1; left: 21px; top: 0px; position: absolute; height: 313px;
    width: 983px">
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="Entitlementdlist" runat="server" AutoPostBack="true" Visible="true"
            ToolTip="All the Requests in this dropdown are Entitlement Requests only">
        </asp:DropDownList>
        <%--asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>--%>
        <asp:ListView ID="listview1" runat="server" ItemPlaceholderID="itemplaceholder" >

            <ItemTemplate>
                <table style="border:1px solid black;">
                    <tr>
                        <td>Report Name</td>
                        <td><asp:TextBox ID="ReportNameLbl" runat="server" Text='<%#Eval("REPORT_DESCRIPTION.rptdesctext") %>' Width="500"></asp:TextBox> </td>
                        <td>
                        <asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal">
                             <asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
                                <asp:ListItem Text="No" Value="No"></asp:ListItem>
                            </asp:CheckBoxList>
                        </td>
                    </tr>
                    <tr>
                        <td>Content Description</td>
                        <td>
                        <asp:Label ID="ContentDescLbl" Text='<%#Eval("REPORT_REQUEST.StopLossMax") %>' runat="server" ></asp:Label>
                        </td>
                        <td>
                        <asp:CheckBoxList ID="CheckBoxList2" runat="server" RepeatDirection="Horizontal">
                             <asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
                                <asp:ListItem Text="No" Value="No"></asp:ListItem>
                            </asp:CheckBoxList>
                        </td>




                    </tr>
                    <tr>

                    <td>
                    Frequency
                    </td>
                    <td>
                     <asp:Label ID="frequencyLbl" Text='<%#Eval("REPORT_REQUEST.reportfrequency") %>' runat="server" ></asp:Label>
                    </td>
                    <td>
                    <asp:CheckBoxList ID="CheckBoxList3" runat="server" RepeatDirection="Horizontal">
                             <asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
                                <asp:ListItem Text="No" Value="No"></asp:ListItem>
                            </asp:CheckBoxList>
                    </td>
                    </tr>
                    <tr>
                    <td>
                    Recepients
                    </td>
                    <td colspan="2">
                    <td>
                    <asp:ListView ID = "lstview2" runat = "server" >
                     </asp:ListView>
                    </td>
                    </td>
                    </tr>
                </table>

                </asp:Table>--%>
            </ItemTemplate>
        </asp:ListView>
    </div>
    </form>
</body>
</html>

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    在您的 ListView 中,您必须添加一个包含 PlaceHolder 的 LayoutTemplate:

    <asp:ListView ID="listview1" runat="server" ItemPlaceholderID="itemplaceholder" >
        <LayoutTemplate>
            <asp:PlaceHolder ID="itemplaceholder" runat="server" />
        </LayoutTemplate>
        <ItemTemplate>
            ...
        </ItemTemplate>
    </asp:ListView>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-12
      • 2017-07-11
      • 2019-11-25
      • 2016-05-26
      • 1970-01-01
      • 2011-07-26
      • 2011-11-12
      相关资源
      最近更新 更多