PageIndexChaned event not working

J

Janez

Hi,

I know this question has been asked many times, however I haven't
found any satisfying answer.
I have a datagrid that is bound to a dataset. I have established
paging on the grid (AllowPaging = true), but the PageIndexChanged
event only fires when AutoGenerateColumns is set to true. If I change
this property to false, the event does not fire.
So the paging only works ok when this property is set to true,
otherwise it does not work at all.
Any help?

Janez
 
Y

Yan-Hong Huang[MSFT]

Hello Janez,

As I understand, the question is: How to use PageIndexChanged event when
autogeneratecolumns is false in asp.net datagrid programming.

In MSDN, we have one sample on it.
"Creating a Pageable, Sortable DataGrid"
http://msdn.microsoft.com/library/en-us/dnaspp/html/aspnet-pageablesortable.
asp?frame=true#aspnet-pageablesortable_topic4
Please refer to "Creating a Sortable, Pageable DataGrid" part in this
article.

Please move your databind code to Page_Load to see if it has any effect.

Does that answer your question?

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Janez

Hi,

thank you for your response.
You were right, after I moved my databind code from button_click to
Page_Load the event started to fire as should.
Well, things are a bit complicated now, because I have a lot of panels
on one page, a lot of buttons, so I need to check during the Page_Load
event which control triggered the postback (to know if datagrid must
be bound or not).
However, I think I will manage now (I hope so).

Thanks again
Janez
 
Y

Yan-Hong Huang[MSFT]

Hi Janez,

Glad to know my suggestion works for you. If you have any more concerns on
it, please feel free to post in the group.

Thanks for participating the community.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

I am having this exact same problem. I'm generating the columns in my datagrid dynamically though. Is that what you are doing? In every other scenario paging works fine. I'm a little new to ASP.NET. If I need to move my databind code to Page_Load, how do I determine which control triggered the post back?
 
Y

Yan-Hong Huang[MSFT]

Hi,

A simple way is to a hidden field to indicate it. Thanks.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Top