How to make search page display in grids?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 年 前
Hi,

Currently the default search page displays products in lines. How do I change it to display in grids so that it is consisted with my other pages? Thanks in advance.
13 年 前
have a look at asp:ListView in search.ascx

you could compare the code in this file to the code in templates/categories/ProductsInGrid.ascx
13 年 前
Thank you. I will implement that.
13 年 前
I'm not sure if I did this correctly, but I attempted and is unsuccessful. I tried replacing the following in search.ascx:

<div class="product-list1">
            <asp:ListView ID="lvProducts" runat="server" OnPagePropertiesChanging="lvProducts_OnPagePropertiesChanging">
                <LayoutTemplate>
                    <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
                </LayoutTemplate>
                <ItemTemplate>
                    <div class="item-box">
                        <nopCommerce:ProductBox2 ID="ctrlProductBox" Product='<%# Container.DataItem %>'
                            runat="server" />
                    </div>
                </ItemTemplate>
            </asp:ListView>
        </div>


with

<div class="product-grid">
        <asp:DataList ID="dlProducts" runat="server" RepeatColumns="4" RepeatDirection="Horizontal"
            RepeatLayout="Table" ItemStyle-CssClass="item-box">
            <ItemTemplate>
                <nopCommerce:ProductBox1 ID="ctrlProductBox" Product='<%# Container.DataItem %>'
                    runat="server" />
            </ItemTemplate>
        </asp:DataList>
    </div>
  


Am I missing somthing?

Thanks
13 年 前
Hi

I'm having trouble getting this to work and this is the nearest post - but without an answer.

I've tried several permutations but get different errors each time.

Am I barking up the wrong tree?

Any help would be appreciated.

Thanks
13 年 前
I've got this working fine -- and I even include the count of products found and what I think is an improved paging. See  http://clermontwebsites.com/searchgrid2011Feb21.jpg

I'm overbooked right now, but can point you in the right direction in a few days, if that helps. Contact me directly at brad (at) clermontsoftware.com or clermontwebsites.com if you need something sooner, or as a reminder.
13 年 前
Yeah, I'd appreciate hearing how you got it to work. I'm using v1.6 and it doesn't want to work the way I've tried it...
13 年 前
i'm also interested in the codes as well. thanks
13 年 前
Keep in mind that this customer had unusual data -- no product names, so the SKU was treated as the product name. so, you would have to adjust accordingly.

In Search.ascx, the relevant code is


    <div class="search-results">
        <asp:Label runat="server" ID="lblNoResults" Text="<% $NopResources:Search.NoResultsText %>"
            Visible="false" CssClass="result" />

        <nopcommerce:ProductsGridview1 id="ctrlproductgridview" runat="server" OnCatalogGridviewSorting="gvOnCatalogSorting"
        OnCatalogPageChanging="gvOnCatalogPageChanging" />
    </div>


In ProductsGridview1.ascx, the relevant code is:


<div class="product-gridview">
    <asp:GridView ID="gvCatalog" DataKeyNames="ProductId" runat="server" AllowPaging="False" EnableViewState="true"
        AutoGenerateColumns="False" CellPadding="4" GridLines="None" AllowSorting="true"
        OnRowCreated="gvOnRowCreated"
        OnSorting ="gvOnSorting"
        PageSize="50" CssClass="productsgridtablestyle">
        <RowStyle CssClass="productsgridrowstyle" />
        <AlternatingRowStyle CssClass="productsgridaltrowstyle" />
        <HeaderStyle CssClass="productsgridheaderstyle" />
        <PagerStyle CssClass="productsgridpagerstyle" />
        <Columns>
            <asp:TemplateField HeaderText="Select" HeaderStyle-CssClass="product-select-th">
                <HeaderTemplate>
                    <%--<asp:CheckBox ID="chkSelectAll" runat="server" CssClass="chkheader" />--%>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox runat="server" ID="chkSelect" ValidationGroup="vgAddtoCart" CssClass="chkselect" />
                    <asp:HiddenField ID="hfProductId" runat="server" Value='<%# Eval("ProductId") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Item" SortExpression="Name" HeaderStyle-CssClass="product-name-th" ItemStyle-CssClass="product-name">
                <ItemTemplate>
                    <asp:HyperLink runat="server" ID="hypName" NavigateUrl='<%# GetProductUrl((int)Eval("ProductId")) %>'>
                        <asp:Label ID="lblName" runat="server" Text='<%#Server.HtmlEncode((string)Eval("Name").ToString()) %>' />
                    </asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="ShortDescription" HeaderText="Description" SortExpression="Description" ReadOnly="true" HeaderStyle-CssClass="product-description-th" ItemStyle-CssClass="product-description" />
            <asp:TemplateField HeaderText="Price" SortExpression="Price" HeaderStyle-CssClass="product-price-th" ItemStyle-CssClass="product-price-td">
                <ItemTemplate>
                    <nopCommerce:ProductPrice2 ID="ctrlProductPrice" runat="server" ProductID='<%#Eval("ProductId") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Qty" HeaderStyle-CssClass="product-quantity-th">
                <ItemTemplate>
                    <asp:TextBox runat="server" ID="txtQuantity" ValidationGroup="vgAddtoCart" CssClass="product-quantity" MaxLength="5" Text="0" />
                    <asp:RangeValidator id="valrngtxtQuantity" ControlToValidate="txtQuantity" runat="server" ValidationGroup="vgAddtoCart"
                        MinimumValue="0" MaximumValue="99999" Type="Integer" ErrorMessage="0 to 99999" SetFocusOnError="True" Display="Dynamic"  />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False" HeaderStyle-CssClass="product-buttons">
                <ItemTemplate>
                    <asp:Button runat="server" ID="btnAddToCart" OnCommand="btnAddToCart_Click" Text="<% $NopResources:Products.AddToCart %>"
                        ValidationGroup="vgAddtoCart" CommandArgument='<%# Eval("ProductId") %>' CssClass="productlistaddtocartbutton" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <div class="clear">
    </div>
    <div class="product-pager">
        <nopcommerce:GridViewPager runat="server" ID="catalogPager" OnPageChanging="PagerOnChanging" TotalRecordText="Total Products Found: " />
    </div>

    <asp:LoginView ID="lgvAddAllToCart" runat="server">
        <LoggedInTemplate>
            <asp:Panel runat="server" id="pnlAddToCart" CssClass="pnladdtocart">
                <span class="addalltocarttext">Add all items with quantities to cart</span>
                                            
                <span class="button">
                    <asp:Button runat="server" ID="btnAddAllToCart" Text="Add All to Cart"
                        ValidationGroup="vgAddtoCart" OnClick="btnAddAllToCart_Click" CssClass="productlistaddtocartbutton">
                    </asp:Button>                                      
                </span>  
            </asp:Panel>
        </LoggedInTemplate>
    </asp:LoginView>
</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.