PageIndexChanged not firing in DataGrid

R

Rick Strahl [MVP]

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
 
A

Alvin Bruney

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
 
V

vMike

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!
 
R

Rick Strahl [MVP]

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
 
Joined
Aug 11, 2009
Messages
1
Reaction score
0
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top