0

i've got this code:

<asp:LinqDataSource ID="Linq1" runat="server" />

    <asp:ListView
        ID="ListView1"
        runat="server"
        DataSourceID="Linq1"
        >
        <ItemTemplate>

            <li class="post">
                <h2 class="text_center"><%# Eval("title")%></a></h2>
                <div class="post_thumb">
                    <a href="single.html">
                        <img src='<%# Eval("image")%>' alt="Post1" /></a>
                </div>
                <div class="entry">
                    <%# Eval("content")%>
                </div>
                <ul class="post_info">
                    <li class="blog_date">
                        <span class="circ">1</span> May 2013
                    </li>
                    <li class="comments">
                        <span class="circ">14</span> Comments
                    </li>
                    <li class="read_more">
                        <a href="single.html"><%# Eval("description")%></a>
                    </li>
                </ul>
            </li>

        </ItemTemplate>
    </asp:ListView>
    <asp:DataPager ID="DataPager1" runat="server" PageSize="1" PagedControlID="ListView1">
        <Fields>
            <asp:NumericPagerField />
        </Fields>
    </asp:DataPager>

And:

    Protected Sub Linq1_Selecting(sender As Object, e As LinqDataSourceSelectEventArgs) Handles Linq1.Selecting
    e.Result = (From j In DB.DataClasses.CMSObjects.ToArray
                Where j.type_id = 4
                Select Title = j.title,
                Content = j.content,
                Image = "/dyncontent/cmsobject/" & j.image,
                Description = j.description)
End Sub

The listview shows the items, it selects the right items from the DB and displays them when i put the pagesize to 10 or something, but when the pagesize is 1 and theres lets say 2 items that are pulled from the DB, Its creating the 2 pages, but when I click "2" to switch to the 2nd item, it doesnt change, it stays at the first item, any ideas?

Update

Whenever I click "2" to go to the second item, I get this error in the Chrome Console:

Uncaught TypeError: object is not a function %D7%91%D7%9C%D7%95%D7%92:89
__doPostBack %D7%91%D7%9C%D7%95%D7%92:89
(anonymous function)

And it still doesnt change to the 2nd item, any help?

  • Where is the OnPagePropertiesChanging event handler? In order to navigate the second page, you have to use the OnPagePropertiesChanging handler method. . Check this http://stackoverflow.com/questions/3204600/how-do-i-use-a-datapager-with-server-side-paging – Deepu Madhusoodanan Jul 07 '14 at 13:35

1 Answers1

0

You already have the datapager, I think you just need to add some code to handle the pagepropertieschange event, which allows you to specify what rows you want to display.

Check out this blog post, looks like youre pretty close... http://weblogs.asp.net/hajan/paging-listview-using-datapager-without-using-datasource-control

ewitkows
  • 3,528
  • 3
  • 40
  • 62