Paging to the next page always gives me the first page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cmrchs@gmail.com

    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
  • Patrice

    #2
    Re: Paging to the next page always gives me the first page

    Do you rebind your date to the grid on each postback ?

    <cmrchs@gmail.c oma écrit dans le message de groupe de discussion :
    0021d58e-0cc4-4e11-93e5-246a9cf4adf3...l egroups.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

    Comment

    • Christian Cambier

      #3
      Re: Paging to the next page always gives me the first page

      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.c oma écrit dans le message de groupe de discussion :
      0021d58e-0cc4-4e11-93e5-246a9cf4a...@x4 1g2000hsb.googl egroups.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.P age
      {
      protected void Page_Load(objec t sender, EventArgs e)
      {
      DataGrid1.DataB ind();
      }
      }
      but i still get the problem.

      what do you suggest?

      thank you
      Chris

      Comment

      • Patrice

        #4
        Re: Paging to the next page always gives me the first page

        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 ier@gmail.coma écrit dans le message de
        groupe de discussion :
        adf8b794-b90f-4813-90dd-a69d95ce05be...l egroups.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...@x4 1g2000hsb.googl egroups.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.P age
        {
        protected void Page_Load(objec t sender, EventArgs e)
        {
        DataGrid1.DataB ind();
        }
        }
        but i still get the problem.
        >
        what do you suggest?
        >
        thank you
        Chris

        Comment

        • Christian Cambier

          #5
          Re: Paging to the next page always gives me the first page

          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...@l6 4g2000hse.googl egroups.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.c oma écrit dans le message de groupe de discussion :
          0021d58e-0cc4-4e11-93e5-246a9cf4a...@x4 1g2000hsb.googl egroups.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.P age
          {
          protected void Page_Load(objec t sender, EventArgs e)
          {
          DataGrid1.DataB ind();
          }
          }
          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="Web Form1.aspx.cs" Inherits="CShar pWebApp.WebForm 1" %>

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

          <html xmlns="http://www.w3.org/1999/xhtml" >
          <head runat="server">
          <title>Untitl ed Page</title>
          </head>
          <body>
          <form id="form1" runat="server">
          <asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="Tr ue"
          DataSourceID="S qlDataSource1">
          </asp:DataGrid>
          <asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
          ConnectionStrin g="<%$
          ConnectionStrin gs:NorthwindCon nectionString %>"
          SelectCommand=" SELECT * FROM [Products]"></asp:SqlDataSour ce>
          </form>
          </body>
          </html>

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

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

          any ideas?

          Chris

          Comment

          • Patrice

            #6
            Re: Paging to the next page always gives me the first page

            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



            Comment

            • cmrchs@gmail.com

              #7
              Re: Paging to the next page always gives me the first page

              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

              Comment

              Working...