Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Paging to the next page always gives me the first page

Reply
Thread Tools

Paging to the next page always gives me the first page

 
 
cmrchs@gmail.com
Guest
Posts: n/a
 
      07-23-2008
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
 
Reply With Quote
 
 
 
 
Christian Cambier
Guest
Posts: n/a
 
      07-23-2008
On Jul 23, 5:42 pm, "Patrice" <http://www.chez.com/scribe/> wrote:
> Do you rebind your date to the grid on each postback ?
>
> <(E-Mail Removed)> a écrit dans le message de groupe de discussion :
> (E-Mail Removed)...
>
> > 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
 
Reply With Quote
 
 
 
 
Christian Cambier
Guest
Posts: n/a
 
      07-23-2008
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" <(E-Mail Removed)> a écrit dans le message de
> groupe de discussion :
> (E-Mail Removed)...
>
> > On Jul 23, 5:42 pm, "Patrice" <http://www.chez.com/scribe/> wrote:
> >> Do you rebind your date to the grid on each postback ?

>
> >> <(E-Mail Removed)> a écrit dans le message de groupe de discussion :
> >> (E-Mail Removed)...

>
> >> > 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">
<aspataGrid ID="DataGrid1" runat="server" AllowPaging="True"
DataSourceID="SqlDataSource1">
</aspataGrid>
<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
 
Reply With Quote
 
cmrchs@gmail.com
Guest
Posts: n/a
 
      07-23-2008
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


I don't have any problems with the GridView.
it's just that, I am preparing a course and in order to explain
ADO.NET in detail, for me things can be explained more clearly using
the DatGrid and SqlDataAdapter as I have done in the past.

I guess I'll have to find another way to explain it.

than you again for your time
best regards
Chris
 
Reply With Quote
 
cmrchs@gmail.com
Guest
Posts: n/a
 
      07-23-2008
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
 
Reply With Quote
 
cmrchs@gmail.com
Guest
Posts: n/a
 
      07-23-2008
On Jul 23, 8:30 pm, (E-Mail Removed) wrote:
> 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

>
> I don't have any problems with the GridView.
> it's just that, I am preparing a course and in order to explain
> ADO.NET in detail, for me things can be explained more clearly using
> the DatGrid and SqlDataAdapter as I have done in the past.
>
> I guess I'll have to find another way to explain it.
>
> than you again for your time
> best regards
> Chris



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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paging gives error in datagrid. archana ASP .Net 0 09-10-2007 04:31 AM
Datagrid custom paging always loads page 1 Julia B ASP .Net Web Controls 2 04-11-2006 02:45 PM
First statement always evaluated first? tconkling C Programming 3 07-09-2005 10:05 PM
CurrentElement->next = CurrentElement->next->next (UNDEFINED?) Deniz Bahar C Programming 2 03-09-2005 12:45 AM
Custom paging problems - first page always displayed Oleg Ogurok ASP .Net Datagrid Control 0 07-08-2003 09:10 PM



Advertisments