我有这段代码:
<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>
和
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
列表视图显示项目,它从数据库中选择正确的项目并在我将pagesize设置为10或者其他内容时显示它们,但是当pagesize为1并且theres允许说出从DB中提取的2个项目时创建2个页面,但当我点击“2”切换到第2个项目时,它没有改变,它停留在第一个项目,任何想法?
更新
每当我点击“2”转到第二项时,我都会在Chrome控制台中收到此错误:
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)
它仍然没有改变第二项,任何帮助?
答案 0 :(得分:0)
您已经拥有了数据管理器,我认为您只需添加一些代码来处理pagepropertieschange事件,该事件允许您指定要显示的行。
查看此博文,看起来非常接近...... http://weblogs.asp.net/hajan/paging-listview-using-datapager-without-using-datasource-control