Datagrid PageIndexChanged event handling

Discussion in 'ASP .Net' started by Gopalan, Jun 18, 2005.

  1. Gopalan

    Gopalan Guest

    Hi

    I have got a Datagrid populated with a Dataset.

    The first time the datagrid shows the first page data.

    When I clicked the Next link to display the next page data it displays the
    same data again.

    I tested whether the event handling function is being called or not, it
    seems it is not called when I click the Next button.

    private void dgWebStatistics_PageIndexChanged(object sender,
    DataGridPageChangedEventArgs e)

    {

    try

    {

    dgWebStatistics.SelectedIndex=-1;

    dgWebStatistics.CurrentPageIndex = e.NewPageIndex;


    }

    catch(Exception Ex)

    {

    }

    finally

    {

    }

    }

    Please help me in finding out the error in this.

    Thanks

    BG
     
    Gopalan, Jun 18, 2005
    #1
    1. Advertising

  2. Gopalan

    Joe Fallon Guest

    Check your page load code.
    You should only bind the data to the grid during initial page load not
    during IsPostback.
    --
    Joe Fallon



    "Gopalan" <> wrote in message
    news:...
    > Hi
    >
    > I have got a Datagrid populated with a Dataset.
    >
    > The first time the datagrid shows the first page data.
    >
    > When I clicked the Next link to display the next page data it displays the
    > same data again.
    >
    > I tested whether the event handling function is being called or not, it
    > seems it is not called when I click the Next button.
    >
    > private void dgWebStatistics_PageIndexChanged(object sender,
    > DataGridPageChangedEventArgs e)
    >
    > {
    >
    > try
    >
    > {
    >
    > dgWebStatistics.SelectedIndex=-1;
    >
    > dgWebStatistics.CurrentPageIndex = e.NewPageIndex;
    >
    >
    > }
    >
    > catch(Exception Ex)
    >
    > {
    >
    > }
    >
    > finally
    >
    > {
    >
    > }
    >
    > }
    >
    > Please help me in finding out the error in this.
    >
    > Thanks
    >
    > BG
    >
    >
     
    Joe Fallon, Jun 18, 2005
    #2
    1. Advertising

  3. Ya, check the IsPostBack in the Page_Load(), and you forget to rebind the
    datagrid after in the PageIndexChanged event there.

    Good luck !
     
    =?Utf-8?B?YWx2aW56X2M=?=, Jun 18, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWlrZUc=?=
    Replies:
    0
    Views:
    489
    =?Utf-8?B?TWlrZUc=?=
    Jun 18, 2004
  2. steve
    Replies:
    0
    Views:
    198
    steve
    Dec 16, 2003
  3. Kilic Beg
    Replies:
    0
    Views:
    154
    Kilic Beg
    Jun 8, 2004
  4. Datagrid PageIndexChanged event doesn't fire

    , Jul 16, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    330
    Teemu Keiski
    Jul 18, 2006
  5. Vijay

    Datagrid PageIndexChanged event not firing

    Vijay, Aug 24, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    449
    Vijay
    Aug 24, 2005
Loading...

Share This Page