updatepanel - repeater control with ajax update panel for Paging -


i have change code. add updatepanel , link buttons

markup

 <asp:updatepanel id="updatepanel1" runat="server">                                     <contenttemplate>                                         <asp:linkbutton id="btnprev" runat="server" onclick="btnprev_click">prevbutton</asp:linkbutton>                                        <asp:textbox id="txthidden" style="width: 28px" value="1" runat="server" />                                         <asp:linkbutton id="btnnext" runat="server" onclick="btnnext_click">nextbutton</asp:linkbutton>                                         <asp:repeater id="repeater1" runat="server" >                                             <itemtemplate>                                                 <div class="latnewstitle">                                                     date:</div>                                                 <%#databinder.eval(container.dataitem, "date")%><br />                                                 <div class="latnewstitle">                                                     title:</div>                                                 <div class="latnewscontent">                                                     <%#databinder.eval(container.dataitem, "title")%></div>                                                 <asp:hyperlink id="lnkdetails" runat="server" navigateurl='<%# eval("item_id", "~/details.aspx?id={0}") %>'>see details</asp:hyperlink>                                                  <br />                                                 <br />                                                 <hr width="100px" />                                                 <br />                                             </itemtemplate>                                         </asp:repeater>                                         </div>                                      </contenttemplate>                                 </asp:updatepanel> 

my code behind

 public property pgnum() integer             if viewstate("pgnum") isnot nothing             return convert.toint32(viewstate("pgnum"))         else             return 0         end if     end     set(value integer)         viewstate("pgnum") = value      end set end property   protected sub page_load(sender object, e eventargs)     if not page.ispostback         bindrepeater()     end if end sub 

i add bindrepeater sub bind datato repeater

 protected sub bindrepeater()          dim strsql string = "select  * news order news.item_id desc"         dim sqlconn new sqlconnection          sqlconn.connectionstring = configurationmanager.connectionstrings("mycon").tostring          sqlconn.open()         dim cmd new sqlcommand(strsql, sqlconn)        dim da new sqldataadapter(cmd)     dim ds new dataset     da.fill(ds)     cnt = ds.tables(0).rows.count     'dim table new datatable()     'da.fill(table)      dim pds new pageddatasource()     pds.datasource = ds.tables(0).defaultview     pds.allowpaging = true     pds.pagesize = 5     pds.currentpageindex = pgnum      txthidden.text = pgnum     dim vcnt integer = cnt / pds.pagesize     if pgnum < 1         btnprev.visible = false     elseif pgnum > 0         btnprev.visible = true     end if      if pgnum = vcnt         btnnext.visible = false     elseif pgnum < vcnt         btnnext.visible = true     end if      repeater1.datasource = pds     repeater1.databind()      sqlconn.close() end sub 

'my paging buttons

protected sub btnnext_click(sender object, e system.eventargs) handles btnnext.click     pgnum += 1     bindrepeater() end sub   protected sub btnprev_click(sender object, e system.eventargs) handles btnprev.click     pgnum -= 1     bindrepeater() end sub   protected sub page_init(sender object, e system.eventargs) handles me.init     bindrepeater() end sub 

my problem next button goes +2 , previous button -2.

thank you


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -