Click here to Skip to main content
15,908,115 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi all....
i have ListView Contol LIke This:
XML
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="5">
                                   <Fields>
                                       <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
                                   </Fields>
                               </asp:DataPager>
                               <asp:ListView ID="ListView1" runat="server">
                                   <LayoutTemplate>
                                       <table border="0px" width="700px" cellspacing='0px' cellpadding="0px">
                                           <tr id="itemPlaceholder" runat="server">
                                           </tr>
                                       </table>
                                   </LayoutTemplate>
                                   <ItemTemplate>
                                       <tr style="background-color: #A52A2A; color: White; text-indent: 20px;">
                                           <td align="left">
                                               <asp:Label runat="server" ID="lblId"><%# Eval("name") %></asp:Label>
                                           </td>
                                           <td align="right">
                                               <asp:Label runat="server" ID="lblName"><%#Eval("schdule")%></asp:Label>
                                           </td>
                                       </tr>
                                       <tr>
                                           <td colspan='2' style="text-indent: 10px;">
                                               <asp:Label runat="server" ID="lblName1"><%#Eval("message")%></asp:Label>
                                               <br />
                                               <br />
                                               <br />
                                           </td>
                                       </tr>
                                   </ItemTemplate>
                                   <SelectedItemTemplate>
                                       <tr runat="server" style="background-color: Yellow;">
                                           <td align="left">
                                               <asp:Label runat="server" ID="lblId1"><%#Eval("name") %></asp:Label>
                                           </td>
                                           <td align="right">
                                               <asp:Label runat="server" ID="lblName2"><%#Eval("schdule")%></asp:Label>
                                           </td>
                                       </tr>
                                   </SelectedItemTemplate>
                               </asp:ListView>

When i Clicking Next Button Paging not working how can i make DataPager to work with mysql database for listview can any one please help me
Thank You in Advance
Posted

1 solution

For paging to work, what matters is the SQL that requests the current page and also finds out how many pages there are. You don't show any SQL here. Getting a control to do paging but hold all your data in memory is insanity. I assume that you're not doing that. All the controls work fine. They don't care what DB you have, so long as you query it for the data properly. The way you get your data is mostly likely the information we need to understand what you're doing, and what you need to do. You should also define 'not working'. Do you see all your records at once ? Do you see page 1, but the other page links don't work ? Do you see the records for one page and no paging links ?
 
Share this answer
 
Comments
tulasiram3975 10-Jul-11 21:22pm    
mysql statement will be Like this:
MySqlCommand cmd = new MySqlCommand("select * from history order by uid desc", con);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "history");
ListView1.DataSource = ds.Tables["history"];
ListView1.DataBind();
i have more than 20 records here i can see first 10 records only when pressing next button it wont go to next 10 records.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900