c# - custom paging in gridview -
i looking paging(top,bottom) functionality gridview(or databind controls)
i using .net framework 2.0.
i have pointers
thank you
solution: used jquery plugin jquery.tablepagination.0.1.js solution
you can asp:repeater this can handle repeater control.
this aspx page code <asp:repeater id="rptimages" runat="server" onitemcommand="rptimages_itemcommand"> <itemtemplate > <div class="image"> <a ><asp:image id="image1" runat="server" imageurl=' <%# eval("imageurl") %>' /></a> </div> </itemtemplate> </asp:repeater> <asp:repeater id="rptpages" runat="server" onitemcommand="rptpages_itemcommand"> <headertemplate> <table cellpadding="0" cellspacing="0" border="0"> <tr class="text"> <td><b style="color:white;">page:</b> </td> <td> </headertemplate> <itemtemplate> <asp:linkbutton id="btnpage" forecolor="white" commandname="page" commandargument="<%# container.dataitem %>" cssclass="text" runat="server"><%# container.dataitem %> </asp:linkbutton> </itemtemplate> <footertemplate> </td> </tr> </table> </footertemplate> </asp:repeater> code behind page code public void loaddata() { try { pageddatasource pgitems = new pageddatasource(); dataview dv = new dataview(dtimage); pgitems.datasource = dv; pgitems.allowpaging = true; pgitems.pagesize = 8; pgitems.currentpageindex = pagenumber; if (pgitems.pagecount > 1) { rptpages.visible = true; arraylist pages = new arraylist(); (int = 0; < pgitems.pagecount; i++) pages.add((i + 1).tostring()); rptpages.datasource = pages; rptpages.databind(); } else rptpages.visible = false; rptimages.datasource = pgitems; rptimages.databind(); } catch { } } public int pagenumber() { { if (viewstate["pagenumber"] != null) return convert.toint32(viewstate["pagenumber"]); else return 0; } set { viewstate["pagenumber"] = value; } } public void itemget() { try { var images = datacontext.sp_getcards(categoryid); pageddatasource pds = new pageddatasource(); pds.datasource = images; pds.allowcustompaging = true; pds.allowpaging = true; pds.pagesize = 8; pds.currentpageindex = currentpage; lblcurrentpage.text = "page: " + (currentpage + 1).tostring() + " of " + pds.pagecount.tostring(); // disable prev or next buttons if necessary //cmdprev.enabled = !pds.isfirstpage; //cmdnext.enabled = !pds.islastpage; rptimages.datasource = pds; rptimages.databind(); } catch { } } protected void rptpages_itemcommand(object source, repeatercommandeventargs e) { try { pagenumber = convert.toint32(e.commandargument) - 1; loaddata(); } catch { } }
Comments
Post a Comment