Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2004, 05:06 AM
Authorized User
 
Join Date: Apr 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default datagrid not paging properly

Hi all,

I have a datagrid showing the results of a search from a stored procedure.

When trying a search and, for example: 23 records are returned. it shows 5 per page. 'showing 1 to 5 of 23'

When you click on a paging link to see another page it returns all records: ie: 'showing 6-10 of 100'

does anyone know what this could be? I need to sort this out really quickly as it's live!

The thing that's confused me is that I have two almost identical search results pages. One for customer facing (works fine) and one for admin - which has this problem with the paging. Why is the admin one erroring? I believe the only difference is that the admin page passes an extra parameter to the stored procedure. (But it return the correct amount of records to the first page)

(the DataView is cached with the users sessionsID)

cheers in advance,

pete

 
Old July 7th, 2004, 12:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Hope this sample could help u.
Code:
<%@ Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<Script Runat="Server">
  void Page_Load( Object s, EventArgs e )
  {
    if ( !IsPostBack )
      BindData();
  }

  void BindData()
  {
    SqlConnection myConnection;
    SqlDataAdapter myAdapter;
    String sqlString;
    DataSet myDataSet;
    // Get Records From Database
    myConnection = new SqlConnection( "Server=Localhost;uid=sa;Database=Northwind" );
    sqlString = "Select * from Products";
    myAdapter = new SqlDataAdapter( sqlString, myConnection );
    myDataSet = new DataSet();
    myAdapter.Fill( myDataSet, "Products" );
    myDataGrid.DataSource = myDataSet;
    myDataGrid.DataBind();
  }

  void pageGrid( Object s, DataGridPageChangedEventArgs e )
  {
    myDataGrid.CurrentPageIndex = e.NewPageIndex;
    BindData();
  }
</Script>

<html>
<head><title>DataGrid</title></head>
<body>
<form Runat="Server">
<asp:DataGrid id="myDataGrid" AutoGenerateColumns="False" AllowPaging="True"
  PageSize="7" PagerStyle-Mode="NumericPages" PagerStyle-HorizontalAlign="Center"
  onPageIndexChanged="pageGrid" cellpadding=3 Runat="Server">
  <Columns>
    <asp:BoundColumn HeaderText="Product ID" DataField="ProductID"/>
    <asp:BoundColumn HeaderText="Product Name" DataField="ProductName"/>
    <asp:BoundColumn HeaderText="Price" DataField="UnitPrice" DataFormatString="{0:c}"/>
  </Columns>
</asp:DataGrid>
</form>
</body>
</html>
Always:),
Hovik Melkomian.
 
Old July 7th, 2004, 09:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

Could your problem be something that is happening after the page posts back? Could you post any code?

In addition, are you creating the data source once or loading it every time?

Brian
 
Old July 8th, 2004, 05:24 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

100% when Binding Grid the query (used to get data) Parameters values changed

Ahmed Ali
Software Developer





Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom paging in Datagrid with datagrid page count madhusrp ASP.NET 1.0 and 1.1 Professional 12 June 2nd, 2008 01:15 PM
Paging in DataGrid vijay_83 ASP.NET 2.0 Professional 0 September 29th, 2006 02:02 PM
datagrid does SORT integer data properly chayanvinayak Flash (all versions) 3 July 27th, 2006 02:59 PM
Datagrid Paging collie VB.NET 2002/2003 Basics 17 January 25th, 2004 07:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.