Page 1 of 1

Add Lines numbers to products displayed in Catalog Display

Posted: Fri Dec 10, 2010 5:06 am
by RichWendrock
Please add line numbers to each product displayed in the Catalog/Browse.aspx page

Many times we need to work with products in the list. Having a line number will make it much easier to find ones place when returning from the EditProduct page.

Re: Add Lines numbers to products displayed in Catalog Display

Posted: Wed Dec 15, 2010 8:33 am
by s_ismail
Try this code
Locate this code in browse.aspx

Code: Select all

<asp:GridView ID="CGrid" runat="server" AutoGenerateColumns="False" Width="100%"
                                        DataKeyNames="CatalogNodeId,CatalogNodeType" AllowSorting="False" AllowPaging="True"
                                        PageSize="40" OnRowCommand="CGrid_RowCommand" OnRowDataBound="CGrid_RowDataBound"
                                        SkinID="PagedList" ShowHeader="false" DataSourceID="CatalogDs" EnableViewState="false">
                                        <Columns>
and Replace with this code

Code: Select all

  <asp:GridView ID="CGrid" runat="server" AutoGenerateColumns="False" Width="100%"
                                        DataKeyNames="CatalogNodeId,CatalogNodeType" AllowSorting="False" AllowPaging="True"
                                        PageSize="40" OnRowCommand="CGrid_RowCommand" OnRowDataBound="CGrid_RowDataBound"
                                        SkinID="PagedList" ShowHeader="false" DataSourceID="CatalogDs" EnableViewState="false">
                                        <Columns>
                                            <asp:TemplateField>
                                                <HeaderStyle HorizontalAlign="center" Width="54px" />
                                                <ItemStyle Width="78px" HorizontalAlign="Center" />
                                                <ItemTemplate>
                                                    <asp:Label ID="CounterLbl" runat="server" Text='<%# GetCount(Eval("CatalogNodeType")) %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>

Now go Browse.aspx.cs file and place this code anywhere inside the class

Code: Select all

  int i=0;
    protected string GetCount(object value)
    {   
        CatalogNodeType type = (CatalogNodeType)value;
        if (type == CatalogNodeType.Product)
        {
            i++;
            return string.Format("No # {0}",i.ToString());
        }
        return string.Empty;
    }

Re: Add Lines numbers to products displayed in Catalog Display

Posted: Thu Dec 16, 2010 9:59 pm
by RichWendrock
Thanks very much... I modified your code a little to display only the number followed by a dot and then adjusted the width so everything displays on one line.

Here is the new code.

<asp:GridView ID="CGrid" runat="server" AutoGenerateColumns="False" Width="100%"
DataKeyNames="CatalogNodeId,CatalogNodeType" AllowSorting="False" AllowPaging="True"
PageSize="40" OnRowCommand="CGrid_RowCommand" OnRowDataBound="CGrid_RowDataBound"
SkinID="PagedList" ShowHeader="false" DataSourceID="CatalogDs" EnableViewState="false">
<columns>
<asp:TemplateField HeaderText="Sort">
<headerstyle HorizontalAlign="center" Width="54px" />
<itemstyle Width="100px" HorizontalAlign="Center" />
<itemtemplate>
<asp:Label ID="CounterLbl" runat="server" Text='<%# GetCount(Eval("CatalogNodeType")) %>'></asp:Label>
<asp:LinkButton ID="MU" runat="server" CommandName="Do_Up" ToolTip="Move Up" CommandArgument='<%#string.Format("{0}|{1}", Eval("CatalogNodeTypeId"), Eval("CatalogNodeId"))%>'><img src="<%# GetIconUrl("arrow_up.gif") %>" border="0" alt="Move Up" /></asp:LinkButton>
<asp:LinkButton ID="MD" runat="server" CommandName="Do_Down" ToolTip="Move Down" CommandArgument='<%#string.Format("{0}|{1}", Eval("CatalogNodeTypeId"), Eval("CatalogNodeId"))%>'><img src="<%# GetIconUrl("arrow_down.gif") %>" border="0" alt="Move Down" /></asp:LinkButton>
<img src="<%# GetCatalogIconUrl(Container.DataItem) %>" border="0" alt="<%#Eval("CatalogNodeType")%>" />
</itemtemplate>