views:

915

answers:

2

Hi, When I click on a button which is outside of the GridView in my asp.net page, the GridView rowdatabound event is getting fired before OnClick event for the button. I am using the button for custom paging so I need to reverse the order of these events. Any thoughts ??

Thanks in Advance, - Amit

+2  A: 

Possibly because you are calling DataBind() on the GridView in the Page_Load event. You should note that Page_Load will always be called before the event that raised the postback... the Button_Click in your case.

I suggest reading up on the ASP.NET Page Life cycle to learn more.

Cerebrus
Also, smells like a case where a databind in Page_Load does check for Page.IsPostback
icelava
yup, that's what it was. Thanks for your help.
Amit
A: 

perhaps your gridview enableviewstate = false