[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

Datagrid Custom Paging ...stored procecure parameters??

Hi all

I have this stored procedure (from 4GuysFromRolla's site) I'm trying to get working to improve the performance of my datagrid's custom paging (See below) but I can't figure out what parameters to sent it from my codebehind ... I assumed the maximumRows param is my datagrid pagesize and the startRowIndex param is my datagrid  currentpageindex?

Am I sending the right parameters?

-- =======================
-- STORED PROC from 4guysfromrolla
-- =======================

CREATE PROCEDURE PagedResults_New
(
   @startRowIndex      int,
   @maximumRows      int
)
AS
--Create a table variable
DECLARE @TempItems TABLE
(
   ID int IDENTITY,
   EmployeeID int
)
-- Insert the rows from tblItems into the temp. table
INSERT INTO @TempItems (EmployeeID)
SELECT EmployeeID
FROM Employees
-- Now, return the set of paged records
SELECT e.*, d.[Name] as DepartmentName
FROM @TempItems t
   INNER JOIN Employees e ON
      e.EmployeeID = t.EmployeeID
   INNER JOIN Departments d ON
      d.DepartmentID = e.DepartmentID
WHERE ID BETWEEN @startRowIndex AND (@startRowIndex + @maximumRows) - 1
GO

...

PARAMETERS I'M SENDING TO STORED PROC IN MY CODEBEHIND ...mark_Datagrid is the name of my Datagrid :-) ...

                'add startRowIndex parameter
                Dim startRowIndexParam As New SqlParameter("@startRowIndex", SqlDbType.Int, 4)
                startRowIndexParam.Value = mark_Datagrid.CurrentPageIndex
                objCmd.Parameters.Add(startRowIndexParam)

                'add maximumRows parameter
                Dim maximumRowsParam As New SqlParameter("@maximumRows", SqlDbType.Int, 4)
                maximumRowsParam.Value = mark_Datagrid.PageSize
                objCmd.Parameters.Add(maximumRowsParam)


Any help GREATLY appreciated :-)

Thanks
Mark
0
msiedle
Asked:
msiedle
1 Solution
 
arif_eqbalCommented:
I think startRowIndexParam should not be the CurrentPageIndex
It should be      CurrentPageIndex * mark_Datagrid.PageSize

0
 
msiedleAuthor Commented:
Got it in one! Thanks :-)

M
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now