We help IT Professionals succeed at work.

Avoiding onrowcommand event in paging

Sukeshjph asked
Hi in my gridview when i click on page tabs i get to first rowcommand and then paging event.Some pages i am getting error "index out of range",as i am setting the e.commandargument to rowindex and getting it back in rowcommand to acces the servercontrols.But i think during paging it first fires the onrowdatabound and e.commandargument is set to the page no=pageindex+1.That is why i am getting index out of range error as before setting the pageindex it tries to find out e.commandargument.
Watch Question

Software Developer
Top Expert 2006
You need to check the CommandName and treat the CommandArgument differently depending on the command. For a page event, you might get a page number, or you might get text, as in "Last". You don't need to set the NewPageIndex, it is set for you.


Explore More ContentExplore courses, solutions, and other research materials related to this topic.