Click here to Skip to main content
14,607,162 members
Rate this:
Please Sign up or sign in to vote.
See more:
I need some clarification regarding the Page Views count of a site. I have a ASP.Net MVC application and there is a GridView in a page which has paging enabled and contains 10 pages.

So, whenever the user navigates to different pages of the GridView the Page Views count will get increased or it will get increased only when the user navigates to some other page?

Also, the Page Views count will get increased when we download images, pdf, word or any other documents from the site?

Please explain clearly.

Thanks in advance

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

here is an example through which you can show grid with paging..
Below code is for aspx page:
<asp:DataGrid ID="dgadvetise" runat="server" AutoGenerateColumns="False"


                        PageSize="5" AllowPaging="True" AllowSorting="True" DataKeyField="ID">
                        <PagerStyle HorizontalAlign="Center" Mode="NumericPages"


                            <asp:BoundColumn DataField="ID" HeaderText="Image ID" Visible="False" />
                            <asp:BoundColumn DataField="Name" HeaderText="Name" />
                            <asp:BoundColumn DataField="Link" HeaderText="Link" />
                            <asp:TemplateColumn HeaderText="Image">
                                    <ul class="hoverbox">
                                            <a href="#"><img id="imgSmall" src='Picture/<%# DataBinder.Eval(Container, "DataItem.ImagePath") %>' alt="Gallery Image" width="100" height="100" /></a>
                                    <asp:FileUpload ID="flUploadGrid" runat="server" ForeColor="#2A2F0F"></asp:FileUpload>
                                <HeaderStyle Width="110px" />
                            <asp:EditCommandColumn CancelText="Cancel" EditText="Edit" HeaderText="Modify" UpdateText="Update"/>
                            <asp:ButtonColumn CommandName="Delete" Text="Delete" HeaderText="Remove"/>
                    <asp:SqlDataSource ID="nayumaadminconnectionstring" runat="server"

                        ConnectionString="<%$ ConnectionStrings:nayumaConnectionString %>"

                        SelectCommand="SELECT * FROM [Details]"></asp:SqlDataSource>

And the cs page code is:
protected void dgadvetise_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
        dgadvetise.CurrentPageIndex = e.NewPageIndex;

protected void BindGrid()
        cls.PopulateGrid(dgadvetise, "Select ID, Name, Link, ImagePath from Details order by ID", this.Page);

I am using a common class which is mentioned below:
public void PopulateGrid(GridView grdView, string sqlQuery, Page form)
            adp = new SqlDataAdapter(sqlQuery, conn);
            tbl = new DataTable();
            grdView.DataSource = tbl;
        catch (Exception ex)
            MsgBox("Populate GridView Error: " + ex.Message, form);

NB: specify your connection in the class file.

I hope this above code will help you.
ragasai 16-Nov-11 23:08pm

I think you are not clear about my question and I am really sorry about the confusion. I am asking about the Google Analytics kind of Page Views count feature and not paging feature in GridView.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100