PageIndexChanged not firing in DataGrid

Discussion in 'ASP .Net' started by Rick Strahl [MVP], Nov 21, 2003.

  1. Hi all,

    I'm loosing my mind <g>...

    I have a datagrid and I can't for hte live of me not get the
    PageIndexChanged event to fire in my codebehind form.

    <asp:datagrid id="dgErrorLog" runat="server"
    onpageindexchanged="dgErrorLog_OnPageIndexChanged"
    enableviewstate="False" allowpaging="True" pagesize="20"
    autogeneratecolumns="False" width="100%" >


    Nothing that I haven't done a million times before, but on this page the
    event in the codebehind is not firing:

    protected void dgErrorLog_OnPageIndexChanged(object sender,
    DataGridPageChangedEventArgs e)

    {

    this.dgErrorLog.CurrentPageIndex = e.NewPageIndex;

    this.ShowLog();

    }

    All other events in the page are firing just fine and the EventTarget is
    posting to the page just fine. But the event code just doesn't fire.

    I've tried using descriptive referenceing (as above on the page) as well as
    explicit event hookup through VS (so it shows up in InitializeComponent()).
    Neither fires the event...


    Anybody have any idea why this would happen? I've done this a million times,
    but I can't see why in this case event handling is crapping out.

    Any help appreciated...

    +++ Rick ---

    --

    Rick Strahl
    West Wind Technologies
    http://www.west-wind.com/
    http://www.west-wind.com/wwHelp
    ----------------------------------
    Making waves on the Web
     
    Rick Strahl [MVP], Nov 21, 2003
    #1
    1. Advertising

  2. Rick Strahl [MVP]

    Alvin Bruney Guest

    You need to delete the datagrid, save the project. Close studio. Re-open the
    project and add the datagrid back and rehook the handlers. That works about
    75% of the time. I hope you don't fall into the 25%

    regards

    --


    -----------
    Got TidBits?
    Get it here: www.networkip.net/tidbits
    "Rick Strahl [MVP]" <> wrote in message
    news:...
    > Hi all,
    >
    > I'm loosing my mind <g>...
    >
    > I have a datagrid and I can't for hte live of me not get the
    > PageIndexChanged event to fire in my codebehind form.
    >
    > <asp:datagrid id="dgErrorLog" runat="server"
    > onpageindexchanged="dgErrorLog_OnPageIndexChanged"
    > enableviewstate="False" allowpaging="True" pagesize="20"
    > autogeneratecolumns="False" width="100%" >
    >
    >
    > Nothing that I haven't done a million times before, but on this page the
    > event in the codebehind is not firing:
    >
    > protected void dgErrorLog_OnPageIndexChanged(object sender,
    > DataGridPageChangedEventArgs e)
    >
    > {
    >
    > this.dgErrorLog.CurrentPageIndex = e.NewPageIndex;
    >
    > this.ShowLog();
    >
    > }
    >
    > All other events in the page are firing just fine and the EventTarget is
    > posting to the page just fine. But the event code just doesn't fire.
    >
    > I've tried using descriptive referenceing (as above on the page) as well

    as
    > explicit event hookup through VS (so it shows up in

    InitializeComponent()).
    > Neither fires the event...
    >
    >
    > Anybody have any idea why this would happen? I've done this a million

    times,
    > but I can't see why in this case event handling is crapping out.
    >
    > Any help appreciated...
    >
    > +++ Rick ---
    >
    > --
    >
    > Rick Strahl
    > West Wind Technologies
    > http://www.west-wind.com/
    > http://www.west-wind.com/wwHelp
    > ----------------------------------
    > Making waves on the Web
    >
    >
    >
     
    Alvin Bruney, Nov 22, 2003
    #2
    1. Advertising

  3. Rick Strahl [MVP]

    vMike Guest

    I had a similiar problem with Page_Unload. Wouldn't fire no matter what. I
    took the words Page_Unload out, retyped them in and worked like a charm. Who
    knows why? By the way Rick, also wanted to let you know that your article on
    WebRequest/Response was outstanding. I have referred to it many times.
    Thanks!

    "Rick Strahl [MVP]" <> wrote in message
    news:...
    > Hi all,
    >
    > I'm loosing my mind <g>...
    >
    > I have a datagrid and I can't for hte live of me not get the
    > PageIndexChanged event to fire in my codebehind form.
    >
    > <asp:datagrid id="dgErrorLog" runat="server"
    > onpageindexchanged="dgErrorLog_OnPageIndexChanged"
    > enableviewstate="False" allowpaging="True" pagesize="20"
    > autogeneratecolumns="False" width="100%" >
    >
    >
    > Nothing that I haven't done a million times before, but on this page the
    > event in the codebehind is not firing:
    >
    > protected void dgErrorLog_OnPageIndexChanged(object sender,
    > DataGridPageChangedEventArgs e)
    >
    > {
    >
    > this.dgErrorLog.CurrentPageIndex = e.NewPageIndex;
    >
    > this.ShowLog();
    >
    > }
    >
    > All other events in the page are firing just fine and the EventTarget is
    > posting to the page just fine. But the event code just doesn't fire.
    >
    > I've tried using descriptive referenceing (as above on the page) as well

    as
    > explicit event hookup through VS (so it shows up in

    InitializeComponent()).
    > Neither fires the event...
    >
    >
    > Anybody have any idea why this would happen? I've done this a million

    times,
    > but I can't see why in this case event handling is crapping out.
    >
    > Any help appreciated...
    >
    > +++ Rick ---
    >
    > --
    >
    > Rick Strahl
    > West Wind Technologies
    > http://www.west-wind.com/
    > http://www.west-wind.com/wwHelp
    > ----------------------------------
    > Making waves on the Web
    >
    >
    >
     
    vMike, Nov 22, 2003
    #3
  4. Thanks Mike,

    Take them out of the source or the ASPX page? I have to play with that, but
    I'm starting to think that hte issue is that I Cut and Paste the grid into
    this page rather than adding it. But what's weird is that I've checked the
    generated code and it looks fine to me...

    Thanks on the article. Aprreciate the feedback!

    +++ Rick ---

    --

    Rick Strahl
    West Wind Technologies
    http://www.west-wind.com/
    http://www.west-wind.com/wwHelp
    ----------------------------------
    Making waves on the Web


    "vMike" <> wrote in message
    news:bpnkak$mce$...
    > I had a similiar problem with Page_Unload. Wouldn't fire no matter what. I
    > took the words Page_Unload out, retyped them in and worked like a charm.

    Who
    > knows why? By the way Rick, also wanted to let you know that your article

    on
    > WebRequest/Response was outstanding. I have referred to it many times.
    > Thanks!
    >
    > "Rick Strahl [MVP]" <> wrote in message
    > news:...
    > > Hi all,
    > >
    > > I'm loosing my mind <g>...
    > >
    > > I have a datagrid and I can't for hte live of me not get the
    > > PageIndexChanged event to fire in my codebehind form.
    > >
    > > <asp:datagrid id="dgErrorLog" runat="server"
    > > onpageindexchanged="dgErrorLog_OnPageIndexChanged"
    > > enableviewstate="False" allowpaging="True" pagesize="20"
    > > autogeneratecolumns="False" width="100%" >
    > >
    > >
    > > Nothing that I haven't done a million times before, but on this page the
    > > event in the codebehind is not firing:
    > >
    > > protected void dgErrorLog_OnPageIndexChanged(object sender,
    > > DataGridPageChangedEventArgs e)
    > >
    > > {
    > >
    > > this.dgErrorLog.CurrentPageIndex = e.NewPageIndex;
    > >
    > > this.ShowLog();
    > >
    > > }
    > >
    > > All other events in the page are firing just fine and the EventTarget is
    > > posting to the page just fine. But the event code just doesn't fire.
    > >
    > > I've tried using descriptive referenceing (as above on the page) as well

    > as
    > > explicit event hookup through VS (so it shows up in

    > InitializeComponent()).
    > > Neither fires the event...
    > >
    > >
    > > Anybody have any idea why this would happen? I've done this a million

    > times,
    > > but I can't see why in this case event handling is crapping out.
    > >
    > > Any help appreciated...
    > >
    > > +++ Rick ---
    > >
    > > --
    > >
    > > Rick Strahl
    > > West Wind Technologies
    > > http://www.west-wind.com/
    > > http://www.west-wind.com/wwHelp
    > > ----------------------------------
    > > Making waves on the Web
    > >
    > >
    > >

    >
    >
     
    Rick Strahl [MVP], Nov 23, 2003
    #4
  5. Rick Strahl [MVP]

    rohit.shrivastava04@gmail

    Joined:
    Aug 11, 2009
    Messages:
    1
    PageIndexChanged Event

    In order to make sure that PageIndexChanged Event gets fired, need to do 2 things.

    1. set EnableViewState = true

    2. In page load bind the data grid without any condition that is do not check for IsPostBack,

    then PageIndexChanged event gets fired everytime.

    I know this will hit the performance.

    Thanks
    Rohit
     
    rohit.shrivastava04@gmail, Aug 11, 2009
    #5
    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. Will McKee
    Replies:
    0
    Views:
    2,347
    Will McKee
    Feb 23, 2004
  2. steve
    Replies:
    0
    Views:
    208
    steve
    Dec 16, 2003
  3. Will McKee
    Replies:
    8
    Views:
    202
    sharath GT
    Oct 9, 2004
  4. Marc Woolfson

    DataGrid.PageIndexChanged not firing on when 0th page requested

    Marc Woolfson, May 23, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    966
    Scott M.
    May 25, 2007
  5. Vijay

    Datagrid PageIndexChanged event not firing

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

Share This Page