Datalist Paging?

2020-05-07 09:20发布

问题:

i have a datalist that contains dynamic content. i need to enable paging to this datalist. im using asp.net c# under visual studion 2010

please send me the code how to enable the paging to the datalist!

here is the code for the datalist:

<asp:DataList ID="DataList1" runat="server" CellPadding="3" 
                DataSourceID="ObjectDataSource1" BackColor="White" BorderColor="#E7E7FF" 
                BorderStyle="None" BorderWidth="1px" GridLines="Horizontal">
                <AlternatingItemStyle BackColor="#F7F7F7" />
                <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
                <ItemStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
                <ItemTemplate>
                <table>
                <tr>

                    <td colspan="2">
                        <a href="<%#Eval("VendorLink") %>"> <%# Eval("Vendor") %></a>
                    </td>
                </tr>              
                <tr>
                    <td  colspan="2">
                         <a href="<%#Eval("TitleLink") %> "><%# Eval("Title") %></a>
                    </td>

                </tr>
                <tr>
                    <td  colspan="2">
                         <asp:Label ID="DescLabel" runat="server" Text='<%# Eval("Desc") %>' />
                    </td>                  

                </tr>
                <tr>
                    <td  colspan="2">
                    <asp:Label ID="DetailsLabel" runat="server" Text='<%# Eval("Details") %>' />   
                   </td>

                </tr>               

                 <tr>
                   <td>
                    <asp:Label ID="LinksLabel" runat="server" Text='<%# Eval("Links") %>' />
                  </td> 
                </tr>
                <tr>
                   <td> <asp:Label ID="RptIDLabel" runat="server" Text='<%# Eval("RptID") %>' /></td> </tr>
                </table>


                  </ItemTemplate>
                <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
            </asp:DataList>

回答1:

here is the link for datalist paging example..

http://www.codeproject.com/KB/aspnet/paging.aspx

http://www.codeproject.com/KB/aspnet/DataListPaging.aspx

http://www.dotnetjohn.com/articles.aspx?articleid=48

http://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx