Click here to Skip to main content
15,916,601 members
Please Sign up or sign in to vote.
2.14/5 (4 votes)
See more:
we can see the examples in many sites that wile loading a list some limited rows are displayed, and when we hit the more button it loads some more rows in the same list. and again if we hit the more button it loads some more rows and it keeps on loading in steps till the list ends.

i want to do this in asp.net mvc

please help thanks in advance
Posted
Comments
BELGIUMsky 9-May-14 7:17am    
to make it look nice and not reload the page you will have to make an api and a javascript or jquery ajax call to that api
Maciej Los 9-May-14 15:36pm    
What have you done till now? Where are you stuck?
martin_sandi 14-May-14 5:40am    
i have this table but it loads all the data at a time. i want it to load 10 rows initially an then the next 10 on the button click and so on.

<table class="style1" >
<tr style="height: 30px; font-weight: bold; color: #ffffff; background: #E87772; border: 1px solid #E87772">
<td >
Req No.
</td>
<td >
Status
</td>
<td >
Req Date
</td>
@*<td>
Tranx. Id.

</td>*@
<td >
Bank Name
</td>
<td >
Branch Name
</td>
<td >
Amount
</td>
<td >
Deposit Date
</td>
<td >
Remarks
</td>
</tr>
@if (Model.Requests.Count > 0)
{
foreach (var request in Model.Requests)
{
<tr>
<td style="border: 1px solid #6f6d6d">
@request.Id
</td>
<td style="border: 1px solid #6f6d6d">
@request.RequestStatus
</td>
<td style="border: 1px solid #6f6d6d">
@request.RequestDate.ToShortDateString()
</td>
@*<td>
@request.TransactionID
</td>*@
<td style="border: 1px solid #6f6d6d">
@request.BankName
</td>
<td style="border: 1px solid #6f6d6d">
@request.BranchName
</td>
<td style="border: 1px solid #6f6d6d">
@request.DepositAmount
</td>
<td style="border: 1px solid #6f6d6d">
@request.DepositDate.ToShortDateString()
</td>
<td style="border: 1px solid #6f6d6d">
@request.Remarks
</td>
</tr>
}
}
else
{
<tr>
No Fund Requests
</tr>
}

</table>
thursunamy 15-May-14 12:40pm    
http://stackoverflow.com/questions/10104599/loading-data-at-the-end-of-my-table-with-ajax
http://miroprocessordev.blogspot.ca/2012/05/load-partial-page-in-jquery-and-aspnet.html

1 solution

Assuming that you're using SQLServer, it's better to change your stored procedure to just return the number of records that you require to display at any particular time rather than the whole data set.

The rough pattern for the sproc would be something like ...

SQL
CREATE PROCEDURE myQuery
  @Start INT,
  @End INT,
  -- Other parameters
AS
  SELECT ROW_NUMBER() OVER (ORDER BY orderField) AS RowNum, fieldList 
      FROM table
      WHERE RowNum >= @Start AND RowNum < @End
      ORDER BY RowNum


That would suppose that your app will carry out the paging calculations, alternatively, you could, if you wished, change the arguments to PageNumber and RecordsPerPage and do those calculations in the stored procedure.

Hope that's of some help.
 
Share this answer
 

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