Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using gridview to bind 7000 records and am using textbox to search records it s took more time to load.

Below i have attached Coding

Javascript

XML
function BindMembersDetails()
    {
        // to call c# funstion        
       __doPostBack('<%=lnktxtsearch.ClientID %>', '');
    }


XML
Asp.net
<asp:TextBox type="text" placeholder="Search..." class="textbox" runat="server" ID="txtSearchKey" onkeyup="BindMembersDetails()" autofocus></asp:TextBox></div> 


  <asp:GridView ID="grdMemDasboard" runat="server" class="grid grdHouseKeeping" AutoGenerateColumns="false"
                CellPadding="0" BorderColor="#cccccc" CellSpacing="0" BorderWidth="0" EmptyDataText="No Items Added"
                onsorting="grdDasboard_Sorting"
                   AllowSorting="true">
                <%--AllowPaging="true" OnPageIndexChanging="grdItemMaster_PageIndexChanging" PagerSettings-Position="Bottom" PageSize="40" --%>
                <Columns>
                    <asp:TemplateField ItemStyle-CssClass="gridCourse" HeaderStyle-CssClass="gridCourse  gridCourseHeader" HeaderText="Membership Id" Visible="false">                       
                        <ItemTemplate>
                            <asp:LinkButton runat="server" ID="lblMembershipId" Text='<%#Eval("MembershipID") %>' ></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                   
              etc.....

                </Columns>
            <%--    <PagerSettings FirstPageText="First" Mode="NumericFirstLast" LastPageText="Last"
                    PageButtonCount="7" NextPageText="Next" PreviousPageText="Previous" />--%>
            </asp:GridView>

// Repeater for paging 
  <asp:Repeater ID="rptPager" runat="server" >
            <ItemTemplate>
                <asp:LinkButton ID="lnkPage" runat="server" Text = '<%#Eval("Text") %>' CommandArgument = '<%# Eval("Value") %>' Enabled = '<%# Eval("Enabled") %>' OnClick = "Page_Changed"></asp:LinkButton> <%--OnClick = "Page_Changed"--%>
                <asp:HiddenField ID="hdnValue" runat="server" Value='<%# Eval("Value") %>'/>
            </ItemTemplate>
            </asp:Repeater>      
            </div>


XML
Stored Procedure
SELECT ROW_NUMBER() OVER(ORDER BY MM.MemberID DESC) AS RowNumber,
MCM.CategoryName as MembershipName,
      --(case when ISNULL(MCM.IsCorporate,0) = 0 then MM.MemberCode  when ISNULL(MCM.IsCorporate,0) = 1 then (select t.memcode   from @temp t where t.memeberid=mm.MemberID ) end) as MemberCode --MM.MemberCode   
	  MD.MemberCode as MemberCode
	  ,MCM.CategoryID
      ,MM.MemberID  as MembershipID
      ,GU.CardName as PrimaryMember
	  ,(select Count(memberid) from Mem.MemberDetails MD where MD.MemberID=MM.MemberID) as TotalPax --case when isnull(MCM.IsCorporate,0)=0 then '' else MCM.NoOfPax end as TotalPax
	  ,case when MM.Approverflag=1 then 'Approved' when MM.Approverflag=2 then 'Rejected'  else 'Pending' end as [Approval]   
      ,[MembershipCategoryID]
      ,CONVERT(varchar(50),ExpiryDate,103) as ExpiryDate 
	  ,[SecurityDeposit]
	  ,[EntranceFee]
      ,[CorporateName]
      ,[TotalAmount]      
      ,ISNULL(md.[Balance],0.00) as Balance
	  , MCM.IsCorporate  
	  ,(case when ISNULL(MCM.IsCorporate,0) = 1 then MM.CorporateID  when ISNULL(MCM.IsCorporate,0) = 0 then '0' end) as CorporateID  --MM.MemberID
	  , MM.IsActive as IsActive
	  , MD.MemberCode as memcode
	  --,(Select Description from Mem.MemberShipStatusMaster where StatusCode=MM.StatusCode) as Status
     ,case when MM.[IsActive]=1 then 'Active' else 'In-Active' end as [Status]
	 INTO #Results
  FROM [Mem].[MemberMaster] MM 
  inner join [Mem].MembershipCategoryMaster MCM on MCM.CategoryID=MM.MembershipCategoryID
  inner join [Mem].MemberDetails MD on MD.MemberID=MM.MemberID
  inner join [dbo].Guest Gu on GU.guestID=MD.GuestID ORDER BY MD.MemberID desc 
      SELECT @RecordCount = COUNT(*)
      FROM #Results
      SELECT * FROM #Results
      WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
      DROP TABLE #Results
Posted
Comments
phil.o 11-Sep-15 3:16am    
You forgot to ask an actual question.
F-ES Sitecore 11-Sep-15 3:23am    
If a user spent 5 seconds dealing with each of your rows it would take 10 hours to deal with the whole page. This is always going to be slow, the only solution is to do as advised below and use paging or filtering to reduce the number of rows you show a user. Showing 7000 is pointless, no human can deal with that amount of data or do anything meaningful or useful with it.
Philippe Mori 11-Sep-15 12:26pm    
First of all, you have to determine if it is the SQL procedure or the grid view that is slow...

1 solution

What you are trying to do is simply one big abuse. What user will want to see 7000 records? You need to create some alternative design. Say, the query can be designed to allow only limited number of records at a time. One very usual solution is paging:
How To Implement Paging in GridView Control in ASP.NET[^],
http://www.c-sharpcorner.com/UploadFile/rohatash/gridview-paging-sample-in-Asp-Net[^].

—SA
 
Share this answer
 
Comments
Maciej Los 12-Sep-15 17:21pm    
5ed!
Sergey Alexandrovich Kryukov 13-Sep-15 11:39am    
Thank you, Maciej.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900