RadListView控件没有指定项占位符

时间:2013-07-17 09:48:02

标签: c# asp.net telerik

代码:

<telerik:RadListView ID="RadListView1" Width="100%" AllowPaging="True" runat="server"
            Skin="Metro" allowsorting="true" ItemPlaceholderID="ProductsHolder" DataKeyNames="Product_ID" GroupPlaceholderID="CategoryHolder"
           GroupItemCount="4" >
            <GroupTemplate>
              <fieldset style="float: left; width: 330px; margin-right: 15px;">
                    <legend><%#Eval("CATEGORY_NAME") %></legend>
                    <table>
                        <tr>
                            <td>
                               <asp:Panel ID="CategoryHolder" runat="server"></asp:Panel>

                            </td>
                        </tr>
                    </table>
                </fieldset>


            </GroupTemplate>

            <LayoutTemplate>
                <fieldset style="width: 100%; margin: 0 auto; border: none;" id="FieldSet1">
                    <telerik:RadDataPager ID="RadDataPager2" runat="server" PagedControlID="RadListView1"
                        Visible='<%# Container.PageCount != 1%>' Skin="Metro" PageSize="52">
                        <Fields>
                            <telerik:RadDataPagerButtonField FieldType="FirstPrev" FirstButtonText="First" PrevButtonText="Prev"
                                HorizontalPosition="LeftFloat" />
                            <telerik:RadDataPagerButtonField FieldType="Numeric" />
                            <telerik:RadDataPagerButtonField FieldType="NextLast" NextButtonText="Next" LastButtonText="Last"
                                HorizontalPosition="RightFloat" />
                        </Fields>
                    </telerik:RadDataPager>
                    <br />
                    <asp:Panel ID="ProductsHolder" runat="server">
                    </asp:Panel>
                    <table cellpadding="0" cellspacing="4" width="100%;" style="clear: both;">
                        <tr>
                            <td>
                                <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
                                    Visible='<%# Container.PageCount != 1%>' Skin="Metro" PageSize="52">
                                    <Fields>
                                        <telerik:RadDataPagerButtonField FieldType="FirstPrev" FirstButtonText="First" PrevButtonText="Prev"
                                            HorizontalPosition="LeftFloat" />
                                        <telerik:RadDataPagerButtonField FieldType="Numeric" HorizontalPosition="NoFloat" />
                                        <telerik:RadDataPagerButtonField FieldType="NextLast" NextButtonText="Next" LastButtonText="Last"
                                            HorizontalPosition="RightFloat" />
                                    </Fields>
                                </telerik:RadDataPager>
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </LayoutTemplate>
            <EmptyDataTemplate>
                <div style="width: 100%; text-align: center;">
                    <b>No Results Found</b></div>
            </EmptyDataTemplate>
            <ItemTemplate>
                <div style="float: left; padding-bottom: 20px; padding-left: 10px; padding-right: 10px;">
                    <div class="CardItem" style="margin: auto !important;">
                        <div class="cardDisplay">
                            <img src="../App_Themes/VivaTheme/images/loading_big.gif" alt="" onerror="javascript:this.onerror = null;this.src='../images/Orders/VivaNotAvailable.jpg';"
                                onload="RetrievePicture(this,'<%# Eval("PRODUCT_ID")%>');" class="lof-image"
                                width="180" height="117" style="margin-bottom: 5px;" />
                        </div>
                        <div class="points">
                            <%# DataBinder.Eval(Container.DataItem, "SALES_PRICE", "{0:###,###,###,##0.00}") + " " + Eval("CURRENCY_ABREVIATION")%>
                        </div>
                        <hr class="fleft" style="border: 1px solid #D9E1E3; width: 195px;" />
                        <div class="CardItemDesc">
                            <table width="100%" style="display: inline-block;">
                                <tr>
                                    <td>
                                        <%# Eval("PRODUCT_NAME")%>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <telerik:RadRating ID="RadRating1" Skin="Metro" runat="server" Enabled="false" Value='<%# Double.Parse(Eval("SALES_PRICE").ToString()) % 3 +2 %>'>
                                        </telerik:RadRating>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <img src="../images/Orders/AddToCart.png" alt="Add to Cart" height="23" onclick="AddToCart(this, '<%# Eval("PRODUCT_NAME")%>', '<%# Eval("SALES_PRICE") %>', '<%# Eval("CURRENCY_ABREVIATION") %>', '<%# (Eval("UNIT_SYMBOL").ToString()=="K" ? "Kg" : (Eval("UNIT_SYMBOL").ToString() == "U" ? "Pc" : Eval("UNIT_SYMBOL"))) %>', '<%# Eval("PRODUCT_ID") %>', '<%# Telepaty.SecurityHelper.StringEncryptorDecryptor.Instance.EncryptString(Eval("PRODUCT_ID").ToString()) %>');return false;"
                                            class="Clickable fleft" />
                                        <% if (LoggedClient.Current != null)
                                           { %>
                                        <img src="../images/Orders/BuyNow.png" alt="Buy Now" style="padding-left: 30px;"
                                            height="23" onclick="javascript:window.location='Checkout.aspx?pID=<%# Telepaty.SecurityHelper.StringEncryptorDecryptor.Instance.EncryptString(Eval("PRODUCT_ID").ToString()) %>';return false;"
                                            class="Clickable fright" />
                                        <% }
                                           else
                                           { %>
                                        <img src="../images/Orders/BuyNow.png" alt="Buy Now" style="padding-left: 30px;"
                                            height="23" onclick="javascript:window.location='/Login.aspx?ref=anonym&pID=<%# Telepaty.SecurityHelper.StringEncryptorDecryptor.Instance.EncryptString(Eval("PRODUCT_ID").ToString()) %>';return false;"
                                            class="Clickable fright" />
                                        <% }; %>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </ItemTemplate>
        </telerik:RadListView>

服务器端:

protected void Page_Load(object sender, EventArgs e)
{
       if (!IsPostBack)
    {
        RadListView1.DataSource = OrderDataHelper.GetProductByCategoryforGrouping();
        RadListView1.DataBind();
    }
}

RadListView控件没有指定项目占位符 有谁知道为什么会出现这个问题?

2 个答案:

答案 0 :(得分:3)

您在ListView中设置了ItemPlaceholderID="ProductsHolder",但PlaceHolder中没有LayoutTemplate具有给定ID的内容。

只需将此代码添加到LayoutTemplate

即可
   <LayoutTemplate>
      <asp:PlaceHolder ID="ProductsHolder" runat="server"></asp:PlaceHolder>
   </LayoutTemplate>

答案 1 :(得分:0)

您获得的错误意味着您应该在 LayoutTemplate 中声明一个控件,以确定应该实例化(ItemTemplate,EditItemTemplate等。)项目的位置。

有关如何以编程方式构建RadListView的示例,请参阅此实时demo