Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

implement custom paging in gridview against Doc.Lib

$
0
0



As of now i dont have pagination in my gridview for binding the columns in my doclib and perform some ioperations in this grid view.But logically, there will be 10000+ items in the doc lib and i want to implement paging on this gridview.

the issue is that i can write the pageindexchanhing event and bind data-datatable- but for every requestit will will fetch the entire records from the doclib.

how can i avoid this. ie, how to implement Custom Paging in gridview against doclib within my site.

note: i dont want to enable Session on my sp farm.so storing the records in the Session and reading it again for the purpose of custom paging is ruled out in my case.

i have gone through this link for custom paging in asp.net , but it uses session to store the records.

www.aspnethostingnews.com/index.php/archives/1334

<asp:Panel ID="pnlgridview" runat="server"><table><tr><td><asp:GridView ID="gv_Document" runat="server" CssClass="myGridStyle" CellPadding="4" ForeColor="#333333" HeaderStyle-Wrap="true" AutoGenerateColumns="False" PagerSettings-Visible="true" AllowPaging="true" AllowSorting="true" OnPageIndexChanging="gv_Document_PageIndexChanging"><%--<AlternatingRowStyle BackColor="White" />--%><Columns><asp:BoundField DataField="Title" HeaderText="Title" /><asp:BoundField DataField="DISCIPLINE" HeaderText="Discipline" /><asp:BoundField DataField="StdDocNum" HeaderText="StdDocNum" /><asp:BoundField DataField="Revision" HeaderText="Revision" /><asp:BoundField DataField="ApprovalCode" HeaderText="ApprovalCode" /></Columns><PagerStyle HorizontalAlign="Right" /><PagerSettings Mode="Numeric" /></asp:GridView></td></tr></table></asp:Panel>

protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                dtLoadGrid = LoadDatable();
                gv_Document.DataSource = dtLoadGrid;
                gv_Document.DataBind();
            }
        }
private DataTable LoadDatable()
        {
            try
            {
                using (SPSite oSite = new SPSite(SPContext.Current.Web.Url))
                {
                    using (SPWeb oWeb = oSite.OpenWeb())
                    {
                        oWeb.AllowUnsafeUpdates = true;
                        SPList vList = oWeb.Lists.TryGetList("Vendor_Lib");
                        int count = v.ItemCount;
                        SPQuery vquery = new SPQuery();
                        string queryforv= @"<Where>" +"<IsNotNull>" +"<FieldRef Name=StdDocNum/>" +"</IsNotNull>" +"</Where>";
                       vquery.Query = queryforv;
dtLoadGrid = vList.GetItems(vquery).GetDataTable();
                        if (dtLoadGrid.Rows.Count > 0)
                        {


                        }
                    }
                }
            }
            catch (Exception expin)
            {
                throw expin;
            }

            return dtLoadGrid;

        }

        protected void gv_Document_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
        {
            gv_Document.PageIndex = e.NewPageIndex;
            gv_Document.DataSource = LoadDatable();
            gv_Document.DataBind();
        }

Anyone  has done this earlier ?

or if anyone has done the same kind of func.with spgridview control with custom paging imeplemented ?

help is appreciated.










Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>