ListView Custom Paging with Linq using C# and VB.Net in ASP.Net

Last Reply 14 days ago By pandeyism

Posted 15 days ago

hello,

i am using linQ query and data pager to bind listview with sql data source data pager works well but with linQ query data pager not working

pleae advice how i can add paging 

        protected void getorders()
        {

            var q=(from co in db.CustomerOrders
                   join c in db.Customers on co.CustomerID equals c.CustomerID
                   orderby co.OrderID

                   select new
                   {
                       customername=c.Name,
                       customerphone=c.PhoneNumber,
                       customeraddress=c.Address,
                       customeremail=c.Email,

                       orderid=co.OrderID,
                       orderdate=co.OrderDate,
                       orderprice=co.Price,
                       ordercustomfees=co.CustomFees,
                       orderdeliveryfees=co.DeliveryFees,
                       ordertotalfees=co.TotalPrice,
                       orderproducts=co.NumberofProducts,
                       orderpakcages=co.NumberofPackages,
                       orderstatus=co.OrderStatus,

                       CustomerOrderNo=co.CustomerOrderNo,

                       notes=co.Notes,
                       LimitDate = co.LimitDate
                   }).ToList();
               }

 

<asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize ="20" QueryStringField="ID">
    <Fields>
        <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" ButtonCssClass="btn btn-default btn-xs"></asp:NextPreviousPagerField>
        <asp:NumericPagerField></asp:NumericPagerField>
        <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ButtonCssClass="btn btn-default btn-xs" ShowNextPageButton="False" ShowPreviousPageButton="False"></asp:NextPreviousPagerField>
    </Fields>
</asp:DataPager>

 

 

Posted 14 days ago

Hi nauna,

You need to use repeater for paging in listview using linq.

Refer below link -

ASP.Net GridView Custom Paging with Linq using C# and VB.Net