473,326 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Paging to the next page always gives me the first page

Hello,

I have set the Allowpaging property to true in a standard DataGrid-
control (System.Web.UI.WebControls).

when run in the browser i get the first records in the first page,
there are 5 pagesi n total, but when I click on the next page number,
I always get the records of the first page ?

how come?

thank you
Chris
Jul 23 '08 #1
6 2132
Do you rebind your date to the grid on each postback ?

<cm****@gmail.coma écrit dans le message de groupe de discussion :
00**********************************...oglegroups.com...
Hello,

I have set the Allowpaging property to true in a standard DataGrid-
control (System.Web.UI.WebControls).

when run in the browser i get the first records in the first page,
there are 5 pagesi n total, but when I click on the next page number,
I always get the records of the first page ?

how come?

thank you
Chris

Jul 23 '08 #2
On Jul 23, 5:42 pm, "Patrice" <http://www.chez.com/scribe/wrote:
Do you rebind your date to the grid on each postback ?

<cmr...@gmail.coma écrit dans le message de groupe de discussion :
0021d58e-0cc4-4e11-93e5-246a9cf4a...@x41g2000hsb.googlegroups.com...
Hello,
I have set the Allowpaging property to true in a standard DataGrid-
control (System.Web.UI.WebControls).
when run in the browser i get the first records in the first page,
there are 5 pagesi n total, but when I click on the next page number,
I always get the records of the first page ?
how come?
thank you
Chris
hello,

Is that what you mean?

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataGrid1.DataBind();
}
}
but i still get the problem.

what do you suggest?

thank you
Chris
Jul 23 '08 #3
Let's restart fresh. This is not the expected behavior and we can't really
guess what you have done wrong without seeing some code.

I would suggest to simplify your code as much as possible even possibly
providing a fictionous code constructed datatable as a data source and show
us the code around 20 lignes of code should be enough to reproduce this
problem.

My guess was that the data are binded on each postback to the grid causing
the paging mechanism to be reset. But it seems this is not what you were
doing (my suggestion was about what the problem is, not how it should be
fixed, sorry for being unclear)...

How do you bind those data ? Do you do this only on the first run or on each
postback ?

--
Patrice

"Christian Cambier" <ch***************@gmail.coma écrit dans le message de
groupe de discussion :
ad**********************************...oglegroups.com...
On Jul 23, 5:42 pm, "Patrice" <http://www.chez.com/scribe/wrote:
>Do you rebind your date to the grid on each postback ?

<cmr...@gmail.coma écrit dans le message de groupe de discussion :
0021d58e-0cc4-4e11-93e5-246a9cf4a...@x41g2000hsb.googlegroups.com...
Hello,
I have set the Allowpaging property to true in a standard DataGrid-
control (System.Web.UI.WebControls).
when run in the browser i get the first records in the first page,
there are 5 pagesi n total, but when I click on the next page number,
I always get the records of the first page ?
how come?
thank you
Chris

hello,

Is that what you mean?

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataGrid1.DataBind();
}
}
but i still get the problem.

what do you suggest?

thank you
Chris

Jul 23 '08 #4
On Jul 23, 7:30 pm, "Patrice" <http://www.chez.com/scribe/wrote:
Let's restart fresh. This is not the expected behavior and we can't really
guess what you have done wrong without seeing some code.

I would suggest to simplify your code as much as possible even possibly
providing a fictionous code constructed datatable as a data source and show
us the code around 20 lignes of code should be enough to reproduce this
problem.

My guess was that the data are binded on each postback to the grid causing
the paging mechanism to be reset. But it seems this is not what you were
doing (my suggestion was about what the problem is, not how it should be
fixed, sorry for being unclear)...

How do you bind those data ? Do you do this only on the first run or on each
postback ?

--
Patrice

"Christian Cambier" <christian.camb...@gmail.coma écrit dans le message de
groupe de discussion :
adf8b794-b90f-4813-90dd-a69d95ce0...@l64g2000hse.googlegroups.com...
On Jul 23, 5:42 pm, "Patrice" <http://www.chez.com/scribe/wrote:
Do you rebind your date to the grid on each postback ?
<cmr...@gmail.coma écrit dans le message de groupe de discussion :
0021d58e-0cc4-4e11-93e5-246a9cf4a...@x41g2000hsb.googlegroups.com...
Hello,
I have set the Allowpaging property to true in a standard DataGrid-
control (System.Web.UI.WebControls).
when run in the browser i get the first records in the first page,
there are 5 pagesi n total, but when I click on the next page number,
I always get the records of the first page ?
how come?
thank you
Chris
hello,
Is that what you mean?
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataGrid1.DataBind();
}
}
but i still get the problem.
what do you suggest?
thank you
Chris
thank you for your time!

here's what i\ve done.

In design mode: I drag a datagrid control on the webform. I configure
the datasource using the wizard that appears so I specify:
the data connection , the sql-select statement and that's it.

the code generated in my webform1.aspx is:

<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="CSharpWebApp.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True"
DataSourceID="SqlDataSource1">
</asp:DataGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT * FROM [Products]"></asp:SqlDataSource>
</form>
</body>
</html>

and added in the code behind-file:
protected void Page_Load(object sender, EventArgs e)
{
//if (! IsPostBack)
DataGrid1.DataBind();
}

it doesn't work, with or without the commented line
only the first records are shown.

any ideas?

Chris
Jul 23 '08 #5
Sorry. I just noticed you are really using a DataGrid ? Are you still using
..NET 1.1 ? 2.0 I would say as you are using a SqlDataSource which is likely
new also in 2.0.

The DataGrid is AFAIK here mainly for legacy support. I would strongly
suggest to use a GridView instead. If you can then :
- replace your DataGrid control with a GridView.
- suppress the DataBind call, this is done for you when using a GridView
control

and paging should work wihtout any other change !!!

IMO the problem is that the DataGrid is AFAIK here mainly for legacy support
and perhaps doesn't support all the features against the newer data sources
(not sure but I believe we had to code for handling sorting and perhaps in
some cases paging depending on the datasource, this is doen automatically in
most if not all cases when using a GridView). I'm afraid that if you need to
keep using a DataGrid control you'll have to implement custom code to handle
paging.

Is using a GridView acceptable ?

--
Patrice

Jul 23 '08 #6
On Jul 23, 8:17 pm, "Patrice" <http://www.chez.com/scribe/wrote:
Sorry. I just noticed you are really using a DataGrid ? Are you still using
.NET 1.1 ? 2.0 I would say as you are using a SqlDataSource which is likely
new also in 2.0.

The DataGrid is AFAIK here mainly for legacy support. I would strongly
suggest to use a GridView instead. If you can then :
- replace your DataGrid control with a GridView.
- suppress the DataBind call, this is done for you when using a GridView
control

and paging should work wihtout any other change !!!

IMO the problem is that the DataGrid is AFAIK here mainly for legacy support
and perhaps doesn't support all the features against the newer data sources
(not sure but I believe we had to code for handling sorting and perhaps in
some cases paging depending on the datasource, this is doen automatically in
most if not all cases when using a GridView). I'm afraid that if you need to
keep using a DataGrid control you'll have to implement custom code to handle
paging.

Is using a GridView acceptable ?

--
Patrice

Patrice,

is it still possible to use the sqlDataAdapter, 'cause adding it to
the toolbox doesn't work (see post in this newsgroup "can not add the
SqlDataAdapter to the toolbox ???")

'cause without it i don't see how i can use the DataSet in the new
method, with the GridView and SqlDataSource-control

thank you
Chris
Jul 23 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned...
5
by: Patrick.O.Ige | last post by:
Hi Guys, I have a datagrid wit editing and updating. But after adding Paging IT WON'T PAGE!! It compiles well but when i click on the paging link it doesn't go to the next link.. When i remove...
4
by: Happy | last post by:
hi I got a datagrid with Paging enabled which is getting populated thru a stored proc. I've given the code in the event grid.CurrentPageIndex = e.NewPageIndex grid.VirtualItemCount =...
8
by: Matthew Curiale | last post by:
I am creating an app that lists clients of a company for management of different attributes for that company. The first page is a listing of the companies currently in the database. I have my...
3
by: Pat | last post by:
I have a 2 nested Datagrid. When i select a row in the Master Datagrid i populate the Child databrid using myDataGrid.SelectedIndex value as the filter and setting the DataKeyField. I enabled...
0
by: Guy W via DotNetMonster.com | last post by:
I read and tried to use the repeater paging method I found on 4 Guys from Rolla (I've tried others also) but it doesn't seem to work. Please see the code I have below and tell me what I may be...
0
by: news.ipartners.pl | last post by:
Hello, I've run across problem with paging in gridview. I have 2 elementson my web page - drop down list filled with manufacturers and grid view for displaying data connected with certain...
2
by: saviomf | last post by:
Hi all, I have a problem with my paging script. The first time it executes, (say it gives 5 pages of records), it will display 1 of 5 but when i click on the next button, it gives 1 of 1 . Please can...
2
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.