It's crazy ! I don't see the fist record - I'm pulling my hair off...

R

Radu

Hi. I use a datagrid. In SQL server 2005 (express) I use some sprocs to
populate table PINS with some.... PINS, of course. I that table I have
created an ID column because I will need to add custom paging in the
datagrid. The ID column is reset everytime I populate that table, so it
begins at 1 and is incremented by 1, of course (I'm using
DBCC CHECKIDENT (PINS, RESEED, 0).

Then on paging I'll use the sproc:
CREATE PROCEDURE [dbo].[SelectPINS]
@StartIndex int = 0,
@EndIndex int = 0
AS

BEGIN
SET NOCOUNT ON;
-->Build the query string:
SELECT PINS.ID, PINS.PIN, PINS.CreateScorecard,
PINS.Bundle, MASTER.lastname,
MASTER.firstname, MASTER.initials,
MASTER.englishdescription,
MASTER.[Temp-Out], MASTER.WorkCentre
FROM
PINS INNER JOIN MASTER ON PINS.PIN = MASTER.PIN
WHERE
PINS.ID > @StartIndex and PINS.ID <=@EndIndex
ORDER BY
PINS.PIN
END

When I run this sproc in 'SQL Server Management', It runs fine and it
returns all the records in table PINS, say 18 records, ID=1...18.

In ASPNET I have the following simple code:
____________________________________________________________________________________
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

m_conScorecards = New SqlConnection("Data
Source='MyComputer\SQLEXPRESS';Initial Catalog='Ordering
Process';Integrated Security=True")
If Not IsPostBack Then
'Get total # of pages:
Dim strSelect As String
strSelect = "Select count(ID) from PINS"
Dim cmdSelect As SqlCommand
cmdSelect = New SqlCommand(strSelect, m_conScorecards)
'Set VirtualItemCount:
m_conScorecards.Open()
dgrPINS.VirtualItemCount = cmdSelect.ExecuteScalar
m_conScorecards.Close()
BindDataGrid()
End If
End Sub
____________________________________________________________________________________

Protected Sub dgrPINS_PageIndexChanged(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
dgrPINS.PageIndexChanged

m_intStartIndex = e.NewPageIndex * dgrPINS.PageSize
dgrPINS.CurrentPageIndex = e.NewPageIndex
BindDataGrid()
End Sub
____________________________________________________________________________________


Private Sub BindDataGrid()

Dim cmdSelect As SqlCommand
Dim dtrDataReader As SqlDataReader

m_intEndIndex = m_intStartIndex + dgrPINS.PageSize
m_conScorecards.Open()
cmdSelect = New SqlCommand("SelectPINs", m_conScorecards)
cmdSelect.Parameters.AddWithValue("@StartIndex", m_intStartIndex)
cmdSelect.Parameters.AddWithValue("@EndIndex", m_intEndIndex)
cmdSelect.CommandType = CommandType.StoredProcedure

dtrDataReader = cmdSelect.ExecuteReader
If dtrDataReader.Read Then
dgrPINS.DataSource = dtrDataReader
dgrPINS.DataBind()
dtrDataReader.Close()
End If
End Sub
____________________________________________________________________________________

As I step through it, I pass to the "SelectPINs" sproc the following
params: intStartIndex=0 and intEndIndex=10, correct.

Still, PIN with ID=1 is always skipped from the datagrid, no matter how
I play with it.

I have simplified the datagrid as much as I could:
<asp:DataGrid ID="dgrPINS"
AllowPaging="true"
AllowCustomPaging="true"
PageSize="10"
AutoGenerateColumns="true"
AllowSorting="True"
runat="server"
/>

Where is my problem ???? I'm going crazy here ! Please help !

Thank you very much, Alex.
 
R

Radu

Radu said:
Hi. I use a datagrid. In SQL server 2005 (express) I use some sprocs to
populate table PINS with some.... PINS, of course. I that table I have
created an ID column because I will need to add custom paging in the
datagrid. The ID column is reset everytime I populate that table, so it.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top