Hello all,

I've been doing some research in paging a datalist / datagrid. Anyone have any tips or methods that you've determined to work the best?

..:: Bare ::..



You want to do the paging on the dataset itself or in the stored procedure? The problem with paging in a dataset is that all the data is returned from the server and loaded in memory now. The upside is that you can sort it anyway you like.

I personally prefer to do the paging in the stored procedure. Here is the general concept that I do in my paging queries:

Procedure GetJournals
@groupID  INT,
@Begin     INT,
@End       INT
AS

--Create temp table as follows:
CREATE TABLE #tmp
(
 UID INT IDENTITY,
 JournalID INT
)

INSERT INTO
  #tmp (JournalID)
SELECT JournalID FROM Journals WHERE GroupID = @GroupID

SELECT Journals.* FROM Journals INNER JOIN #tmp ON #tmp.JournalID = Journals.JournalID WHERE #tmp.ID BETWEEN @Begin AND @End


Go to ItemEvents of Data Grid control that is located at top of the property page.

Create an event for paging .Inside the event write the following code.

MyDataGrid.CurrentPageIndex=e.NewPageIndex;
   BindGrid();

BindGrid ()is a method which will populate date in datagrid from Database.

Then rightclick on datagrid go to property builder

  Go to Paging

  check the allow paging check box.

Set the property for number of records you want to dispaly.

Sanat Kumar Mohapatra

Software Professional

GO

Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....







InstantASP Forums


Search