如何将分页赋予asp:DataList

时间:2011-10-17 09:08:17

标签: c# asp.net

这是我的ASPX代码,但是,我看不到有任何方法可以进行分页

<asp:DataList ID="dlProjectImages" runat="server" RepeatColumns="3"
              RepeatLayout="Table" RepeatDirection="Horizontal" BorderWidth="0px"
              HorizontalAlign="Center" >
    <ItemStyle />
    <ItemTemplate>
        <table border="0" cellpadding="0" border="0" align="center" valign="top">
            <tr>
                <td width="16" align="center" valign="top"></td>

               <td width="169" height="132" align="center" valign="middle" class="top-links01">
                    <a href="Project_Details.aspx?id_Project=<%# Eval("id_Project")%>&type=<%= Request.Params["type"]%>&activity=<%=Request.Params["activity"]%>">
                        <img id="findme" alt="" height="114" src="<%# Eval("Thumbnail_Image") %>" title="Click To View Project Details" border="0" /></a>
                </td>
                <td width="16" align="center" valign="top"></td>
            </tr>
             <tr>
                <td align="center" valign="top" colspan="3">
                    <asp:Label ID="lblProject_name" Font-Bold="true" Text='<%# Eval("Project_Name") %>' CssClass="top-links01" runat="server"></asp:Label><br />
                </td>
            </tr>
            <tr>
                <td colspan="3" align="center"><img src="/images/clear.gif" border="0" height="20px" /></td>
            </tr>
        </table>
    </ItemTemplate>
</asp:DataList>

我错过了哪些可以让我做分页?

2 个答案:

答案 0 :(得分:1)

您可以使用PagedDataSource来分页数据列表。请参阅this article,其详细解释相同。

在相关说明中,为什么不使用ListView - 它可以与DataPager一起用于分页,并提供对生成的标记的完全控制。

答案 1 :(得分:0)

抹于,

我认为你不能使用DataList进行分页。你要么必须按照VinayC提到的文章链接手动实现它,要么切换到GridView,因为它为你做了分页。

查看this MSDN documentation

相关问题