如何从ASP.Net中将大数据从数据库检索到Gridview?没有分页

时间:2018-10-11 07:55:36

标签: c# asp.net sql-server gridview webforms

我有一个gridview,其中绑定了来自数据库的数据。问题是数据大约有12000多行,并且加载网格视图花费了太多时间。我不想在网格中分页。所以没有分页。是否可以使其快速检索?我正在通过存储过程从数据库中获取数据,并且我已将数据库上传到Cloud中。

这是我的存储过程

    SELECT 
    A.ItemCode as 'Item Code'
        ,rtrim(A.PartItemNo)  as 'Item No'
        ,rtrim(A.ItemDesc)  as 'Item Description'
        ,rtrim(IsNull(isnull(Sum(B.INQty),0) + Sum(B.RecQty) + Sum(B.PurRetQty) + Sum(B.RetQty) - ((Sum(B.IssQty) + Sum(B.ChargeOutQty)) ), 0)) As Quantity  
        ,A.ProdCode
        ,A.PurchaseRate
        ,A.SaleRate
        ,A.Source

    from Item A 
    Left outer Join ItemStock B 
    On A.ItemCode=B.ItemCode 
    And A.DealerCode=B.DealerCode 

    Where  (A.DealerCode=@DealerCode and @Category = '')
    or (A.DealerCode=@DealerCode and @Category = 'P' and A.LubeFlag = 'N')
    or (A.DealerCode=@DealerCode and @Category = 'L' and A.LubeFlag = 'Y')
    or (A.DealerCode=@DealerCode and @Category = 'PL' AND Source not in ('C.K.D.' , 'LOCAL'))

    Group by A.ItemCode,A.ItemDesc,A.PartItemNo,A.ProdCode,A.PurchaseRate,A.SaleRate,A.Source Order by A.ItemCode asc 

这是C#Asp.Net中的代码

sQuery = "test '" + Session["DealerCode"].ToString() + "', 'P'";
 if (myFunc.ExecuteQuery(sQuery, ref ds))
{
Session["Parts"] = ds;
if (ds.Tables[0].Rows.Count > 0)
   {
       gvParts.DataSource = ds.Tables[0]; gvParts.DataBind();
       gvParts.HeaderRow.TableSection = TableRowSection.TableHeader;
   }
}

0 个答案:

没有答案