I am working with a two nested data repeaters, and I want to allow paging for the outer repeater.
我正在使用两个嵌套数据中继器,我希望允许为外部中继器分页。
Here is what I have so far:
这是我到目前为止所得到的:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="LinqDataSource1" OnItemDataBound="Repeater1_ItemDataBound">
<HeaderTemplate>
<div class="group">
</HeaderTemplate>
<ItemTemplate>
<div class="question"><%#Eval("QText") %></div>
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%# setQID(Eval("QID"))%>' />
<%-- THE INNER REPEATER--%>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="LinqDataSource2">
<HeaderTemplate>
<div class="answer">
</HeaderTemplate>
<ItemTemplate>
<%# (GetAnswer(Eval("AnsQID"))) != 1 ? (displayAnswer(Eval("AText"))) : ""%>
</ItemTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
</asp:Repeater>
<%-- THE INNER REPEATER ENDS HERE--%>
</ItemTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
</asp:Repeater>
I have googled for this, searched everywhere and found a lot of ways to approach this. I am using LinqDatasources
and two repeaters. What is the best way to do this ?
我在谷歌上搜索了这个,搜索了所有地方,找到了很多方法来解决这个问题。我正在使用linqdatasource和两个中继器。最好的方法是什么?
2 个解决方案
#1
2
To page the outer repeater i have used the method outlined in this post in the past. I don't think it should make much difference to the outcome if your repeater is nested. Your inner repeater will count as one row.
要翻页外中继器,我曾使用过这篇文章中列出的方法。我认为如果你的中继器是嵌套的,对结果不会有太大的影响。你的内部中继器将算作一行。
Repeaters generally though don't have great support for paging. You could consider using ListView (if using ASP.Net 3.5 or greater) or GridView (ASP.Net 2.0 or greater) which have more support for paging out of the box.
但中继器通常不支持分页。您可以考虑使用ListView(如果使用ASP)。或GridView (ASP)。Net 2.0或以上),它有更多的对开箱分页的支持。
#2
1
I have used this control in my Project.
我在我的项目中使用了这个控件。
http://www.codeproject.com/KB/custom-controls/CollectionPager.aspx optional http://www.codeproject.com/KB/webforms/SQLPager_For_Everything.aspx
http://www.codeproject.com/KB/custom-controls/CollectionPager.aspx可选http://www.codeproject.com/KB/webforms/SQLPager_For_Everything.aspx
and for Nested you have to use Databoud event and bound the child repeater.
对于嵌套,您必须使用Databoud事件并绑定子中继器。
#1
2
To page the outer repeater i have used the method outlined in this post in the past. I don't think it should make much difference to the outcome if your repeater is nested. Your inner repeater will count as one row.
要翻页外中继器,我曾使用过这篇文章中列出的方法。我认为如果你的中继器是嵌套的,对结果不会有太大的影响。你的内部中继器将算作一行。
Repeaters generally though don't have great support for paging. You could consider using ListView (if using ASP.Net 3.5 or greater) or GridView (ASP.Net 2.0 or greater) which have more support for paging out of the box.
但中继器通常不支持分页。您可以考虑使用ListView(如果使用ASP)。或GridView (ASP)。Net 2.0或以上),它有更多的对开箱分页的支持。
#2
1
I have used this control in my Project.
我在我的项目中使用了这个控件。
http://www.codeproject.com/KB/custom-controls/CollectionPager.aspx optional http://www.codeproject.com/KB/webforms/SQLPager_For_Everything.aspx
http://www.codeproject.com/KB/custom-controls/CollectionPager.aspx可选http://www.codeproject.com/KB/webforms/SQLPager_For_Everything.aspx
and for Nested you have to use Databoud event and bound the child repeater.
对于嵌套,您必须使用Databoud事件并绑定子中继器。