Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Paging problem

    Hi
    My form includes a dropdown list(DL) that represent types of customers and
    submit button(BTN).
    When I press the BTN it runs a query related to the selected DL and fills a
    datagrid that supports pagination.

    The problem is that if I go to page 15 for example and then replace my DL to
    another type and submit again, if the other type doesn't have 15 pages as
    well, I get error message:
    Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount

    I tried to reset my datagrid for every BTN pressing by using :
    dgSearch.CurrentPageIndex = 0

    dgSearch.DataBind()

    Any help is appreciated!


    Verdict Guest

  2. Similar Questions and Discussions

    1. Recordset paging problem
      I'm stuck on this one My recordset paging wont work. I've done a search page with a form and a table in it to post 2 values to the result page....
    2. Datagrid Paging Problem
      Hi I have 2 linked datagrids on a web page, a master and a detail. Both are set as paged. The first contains accounts and the second contains the...
    3. another problem with paging
      I am having the same problem, How did you solve your problem? I can't open the first link in BalaKrishna's posting and i couldn't find the answer...
    4. Repeater paging problem
      Hi, I'm trying to do the following but I can't understand what's wrong. Could you help me here! I do paging with a Repeater like this: ...
    5. Problem with paging
      I found the solution to that problem ... check if you have then datagrid property DataKeyField defined in your aspx page. Ex: DataKeyField="ID"...
  3. #2

    Default Paging Problem

    I have a SQL Stored Procedure returning a dataset. When
    paging is turned off I get the entire dataset on one long
    page. However when paging is turned on, I get the first
    page and when I go to the next page I get the same data
    on page 2. In other words paging is not working for me.
    Thanks in advance for any suggestions.


    This is my code:

    DS = new DataSet()
    MyCommand.Fill(DS, "Results")





    DataGrid1.DataSource=DS.Tables
    ("Results").DefaultView
    DataGrid1.DataBind()

    Jeff Thur Guest

  4. #3

    Default Paging Problem

    Check out following url

    [url]http://msdn.microsoft.com/library/default.asp?[/url]
    url=/library/en-
    us/dv_vbCode/html/vbtskcodepagingindatagridwebcontrolvisual
    basic.asp

    HTH

    Elton Wang
    [email]elton_wang@hotmail.com[/email]
    >-----Original Message-----
    >I have a SQL Stored Procedure returning a dataset. When
    >paging is turned off I get the entire dataset on one long
    >page. However when paging is turned on, I get the first
    >page and when I go to the next page I get the same data
    >on page 2. In other words paging is not working for me.
    >Thanks in advance for any suggestions.
    >
    >
    >This is my code:
    >
    > DS = new DataSet()
    > MyCommand.Fill(DS, "Results")
    >
    >
    >
    >
    >
    > DataGrid1.DataSource=DS.Tables
    >("Results").DefaultView
    > DataGrid1.DataBind()
    >
    >.
    >
    Elton Wang Guest

  5. #4

    Default Paging problem

    I have a datagrid that only shows 2 items per page. The page numbers appear
    at the bottome of each page for the user to page through the list. It shows
    1 through 10 and then a "..." link. If I click the "..." link I can see
    page numbers 11 through 20 and another "..." link. However if I cllick that
    link, it sends me back to the first 1 through 10 pages instead of 21 through
    30. I know there are enough items that 34 pages should show up. So what is
    the problem?

    also, any of the numbers that I click from 11 to 20 send me back to the
    corresponding number in the 1 through 10 pages... It seems like it's not
    returning the correct numbers to the paging handler...

    Code is as follows:

    private void DataGrid1_PageIndexChanged(object source,
    System.Web.UI.WebControls.DataGridPageChangedEvent Args e)

    {

    this.DataGrid1.CurrentPageIndex = e.NewPageIndex;

    if (this.mdsDataSource != null)

    this.DataGrid1.DataBind();

    }




    Andrea Williams Guest

  6. #5

    Default Paging problem

    Hi Andrea,

    Probably the EnableViewState of your datagrid is false. If
    so, change it to true.

    HTH

    Elton Wang
    [email]elton_wang@hotmail.com[/email]

    >-----Original Message-----
    >I have a datagrid that only shows 2 items per page. The
    page numbers appear
    >at the bottome of each page for the user to page through
    the list. It shows
    >1 through 10 and then a "..." link. If I click the "..."
    link I can see
    >page numbers 11 through 20 and another "..." link.
    However if I cllick that
    >link, it sends me back to the first 1 through 10 pages
    instead of 21 through
    >30. I know there are enough items that 34 pages should
    show up. So what is
    >the problem?
    >
    >also, any of the numbers that I click from 11 to 20 send
    me back to the
    >corresponding number in the 1 through 10 pages... It
    seems like it's not
    >returning the correct numbers to the paging handler...
    >
    >Code is as follows:
    >
    >private void DataGrid1_PageIndexChanged(object source,
    >System.Web.UI.WebControls.DataGridPageChangedEven tArgs e)
    >
    >{
    >
    >this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
    >
    >if (this.mdsDataSource != null)
    >
    >this.DataGrid1.DataBind();
    >
    >}
    >
    >
    >
    >
    >.
    >
    Elton Wang Guest

  7. #6

    Default Re: Paging problem

    That's not it, it's already set to true by default and I have not changed
    it.

    Andrea


    "Elton Wang" <anonymous@discussions.microsoft.com> wrote in message
    news:01b401c53969$fa557120$a601280a@phx.gbl...
    > Hi Andrea,
    >
    > Probably the EnableViewState of your datagrid is false. If
    > so, change it to true.
    >
    > HTH
    >
    > Elton Wang
    > [email]elton_wang@hotmail.com[/email]
    >
    >
    > >-----Original Message-----
    > >I have a datagrid that only shows 2 items per page. The
    > page numbers appear
    > >at the bottome of each page for the user to page through
    > the list. It shows
    > >1 through 10 and then a "..." link. If I click the "..."
    > link I can see
    > >page numbers 11 through 20 and another "..." link.
    > However if I cllick that
    > >link, it sends me back to the first 1 through 10 pages
    > instead of 21 through
    > >30. I know there are enough items that 34 pages should
    > show up. So what is
    > >the problem?
    > >
    > >also, any of the numbers that I click from 11 to 20 send
    > me back to the
    > >corresponding number in the 1 through 10 pages... It
    > seems like it's not
    > >returning the correct numbers to the paging handler...
    > >
    > >Code is as follows:
    > >
    > >private void DataGrid1_PageIndexChanged(object source,
    > >System.Web.UI.WebControls.DataGridPageChangedEven tArgs e)
    > >
    > >{
    > >
    > >this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
    > >
    > >if (this.mdsDataSource != null)
    > >
    > >this.DataGrid1.DataBind();
    > >
    > >}
    > >
    > >
    > >
    > >
    > >.
    > >

    Andrea Williams Guest

  8. #7

    Default Re: Paging problem

    Also, the paging works fine with the page 1 through 10.

    Andrea


    "Elton Wang" <anonymous@discussions.microsoft.com> wrote in message
    news:01b401c53969$fa557120$a601280a@phx.gbl...
    > Hi Andrea,
    >
    > Probably the EnableViewState of your datagrid is false. If
    > so, change it to true.
    >
    > HTH
    >
    > Elton Wang
    > [email]elton_wang@hotmail.com[/email]
    >
    >
    > >-----Original Message-----
    > >I have a datagrid that only shows 2 items per page. The
    > page numbers appear
    > >at the bottome of each page for the user to page through
    > the list. It shows
    > >1 through 10 and then a "..." link. If I click the "..."
    > link I can see
    > >page numbers 11 through 20 and another "..." link.
    > However if I cllick that
    > >link, it sends me back to the first 1 through 10 pages
    > instead of 21 through
    > >30. I know there are enough items that 34 pages should
    > show up. So what is
    > >the problem?
    > >
    > >also, any of the numbers that I click from 11 to 20 send
    > me back to the
    > >corresponding number in the 1 through 10 pages... It
    > seems like it's not
    > >returning the correct numbers to the paging handler...
    > >
    > >Code is as follows:
    > >
    > >private void DataGrid1_PageIndexChanged(object source,
    > >System.Web.UI.WebControls.DataGridPageChangedEven tArgs e)
    > >
    > >{
    > >
    > >this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
    > >
    > >if (this.mdsDataSource != null)
    > >
    > >this.DataGrid1.DataBind();
    > >
    > >}
    > >
    > >
    > >
    > >
    > >.
    > >

    Andrea Williams Guest

  9. #8

    Default Re: Paging problem

    Generally when paging you should re-bind datagrid with its
    data source. I can't see anything else wrong.

    HTH

    Elton Wang
    >-----Original Message-----
    >That's not it, it's already set to true by default and I
    have not changed
    >it.
    >
    >Andrea
    >
    >
    >"Elton Wang" <anonymous@discussions.microsoft.com> wrote
    in message
    >news:01b401c53969$fa557120$a601280a@phx.gbl...
    >> Hi Andrea,
    >>
    >> Probably the EnableViewState of your datagrid is false.
    If
    >> so, change it to true.
    >>
    >> HTH
    >>
    >> Elton Wang
    >> [email]elton_wang@hotmail.com[/email]
    >>
    >>
    >> >-----Original Message-----
    >> >I have a datagrid that only shows 2 items per page.
    The
    >> page numbers appear
    >> >at the bottome of each page for the user to page
    through
    >> the list. It shows
    >> >1 through 10 and then a "..." link. If I click
    the "..."
    >> link I can see
    >> >page numbers 11 through 20 and another "..." link.
    >> However if I cllick that
    >> >link, it sends me back to the first 1 through 10 pages
    >> instead of 21 through
    >> >30. I know there are enough items that 34 pages should
    >> show up. So what is
    >> >the problem?
    >> >
    >> >also, any of the numbers that I click from 11 to 20
    send
    >> me back to the
    >> >corresponding number in the 1 through 10 pages... It
    >> seems like it's not
    >> >returning the correct numbers to the paging handler...
    >> >
    >> >Code is as follows:
    >> >
    >> >private void DataGrid1_PageIndexChanged(object source,
    >> >System.Web.UI.WebControls.DataGridPageChangedEven tArgs
    e)
    >> >
    >> >{
    >> >
    >> >this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
    >> >
    >> >if (this.mdsDataSource != null)
    >> >
    >> >this.DataGrid1.DataBind();
    >> >
    >> >}
    >> >
    >> >
    >> >
    >> >
    >> >.
    >> >
    >
    >
    >.
    >
    Elton Wang Guest

  10. #9

    Default RE: Paging problem

    Hey,

    I have the same problem. Very mysterious. It's the links with postback that have wrong postback information... When you are at the ... 11 12 ... 19 20 ... links then they have the same postback information as 1 2 ... 9 10 ... which means that if you press 11 it will go to page 2 if you press 15 it will go to page 6.

    The question is, why does it generate the same postbacks in both places.

    If you found the aswer please post it here.

    Hördur.

    From [url]http://www.developmentnow.com/g/12_2005_4_0_0_371810/Paging-problem.htm[/url]

    Posted via DevelopmentNow.com Groups
    [url]http://www.developmentnow.com[/url]
    Hordur Hreinsson Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139