Datagrid custom paging problem

S

SStory

After tons of thinking I decided that a dataset for a search could contain
far too much info on the server for an ISP to allow, so I decided to do
custom paging.
I created a stored proc that makes a temporary table. It receives
PageNumber and PerPage properties and can receive a (just return count)
param to just get the count.

So page 1 if we are doing 5 per page would return
records 1,2,3,4,5
page 2 6,7,8,9,10 ,etc.

This all works--the records are based on the temp tables whose first field
is an Identity--only valid in the temp table.
Works great testing from Query Analyzer.

I have it binding to my datagrid and it shows the first page of data.
It doesn't show the page numbers though?
Just a 1.

There should be several pages.

Is that not automatic when it knows how many pages to use and pagenumbers is
turned on?

What am I missing here?

I have an event that handles
Private Sub grdSearchResults_PageIndexChanged(ByVal source As System.Object,
ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
grdSearchResults.PageIndexChanged

intStartIndex = (e.NewPageIndex * grdSearchResults.PageSize)
grdSearchResults.CurrentPageIndex = e.NewPageIndex
BindDataGrid()
End Sub

most of this idea taken from ASP Unleashed book one and modified to use a
stored proc.

Am I doing something wrong?

Sub BindDataGrid()
Dim daResults As SqlDataAdapter
Dim dsResults As DataSet
intEndIndex = intStartIndex + grdSearchResults.PageSize
dim cmdSelect As SqlCommand = New SqlCommand("myStoredProcHere", conn)
cmdSelect.CommandType = CommandType.StoredProcedure
Dim p As New SqlParameter("@Rep_ID", Rep_ID)
cmdSelect.Parameters.Add(p)
p = New SqlParameter("@PageNumber", intStartIndex)
cmdSelect.Parameters.Add(p)
p = New SqlParameter("@PerPage", RESULTS_PERPAGE)
cmdSelect.Parameters.Add(p)
daResults = New SqlDataAdapter(cmdSelect)
dsResults = New DataSet
daResults.Fill(dsResults, "Results")

grdSearchResults.DataSource = dsResults
grdSearchResults.DataBind()
End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim daResults As SqlDataAdapter
Dim dsResults As DataSet
Dim cmdSelect As SqlCommand


If Not IsPostBack Then
' Get Total Pages
cmdSelect = New SqlCommand("MyStoredProcHere", conn)
cmdSelect.CommandType = CommandType.StoredProcedure
p = New SqlParameter("@JustGetCount", 1)
cmdSelect.Parameters.Add(p)
conn.Open()
'get size
grdSearchResults.VirtualItemCount = (cmdSelect.ExecuteScalar() /
grdSearchResults.PageSize)
grdSearchResults.PageSize = RESULTS_PERPAGE
conn.Close()
BindDataGrid()
End If
End Sub

'the HTML; the full declare has column definitions too--they work fine
<asp:datagrid id="grdSearchResults" runat="server" ForeColor="White"
Width="770px" AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True" AllowCustomPaging="True"
BackImageUrl="images/tablehdrbg.jpg" PageSize="3"
PagerStyle-Mode="NumericPages">
<PagerStyle Mode="NumericPages"></PagerStyle>
</asp:datagrid>

I anyone has any ideas as to what I am doing wrong, please let me know.

Shane
 

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