6

编码 :

<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 控件没有指定项目占位符,有人知道为什么会出现这个问题吗?

4

2 回答 2

4

ItemPlaceholderID="ProductsHolder"在 ListView 中设置,但PlaceHolder在您的LayoutTemplate.

只需将此代码添加到您的LayoutTemplate

   <LayoutTemplate>
      <asp:PlaceHolder ID="ProductsHolder" runat="server"></asp:PlaceHolder>
   </LayoutTemplate>
于 2013-07-17T10:01:19.897 回答
1

您收到的错误确实意味着您应该在LayoutTemplate中声明一个控件,以确定应在何处实例化项目(ItemTemplate、EditItemTemplate 等)。

有关如何以编程方式构造 RadListView 的示例,请参阅此现场演示

于 2013-07-17T10:00:07.287 回答