I have a gridview that adds an onclick attribute whenever a row is created. As part of the Javascript method, I attached the following code:
alert('<%=gvxTaskList.PageIndex%>');
But no matter what page I click on, the alert always returns 0 instead of the current page’s index. How do I, through Javascript, obtain the current page index each time a new page is clicked?
You don’t.
Gridview renders as an html table. Javascript knows nothing about GridViews.
You can put the page index in a hidden control and read that.