I am working in C#.Net Gridview Concept. I am having 5 Rows in the gridview. In the second page of the gridview am having another 5 Rows. I am having a EDIT Button in all the rows. In ROW_COMMAND event my code is
int rowIndex = Convert.ToInt32(e.CommandArgument);
HiddenField lbl = (HiddenField)gvItem.Rows[rowIndex].FindControl("hidPI");
string CompChainID = lbl.Value;
When i go to the second page and editing the 2nd row means, i am getting the RowIndex as 6. There i am getting the error. As that page had only 5 Rows.
What should i do for this..
Well
pageIndex*5+rowindexwould do the trick.Or, in your case, just use modulus function:
rowindex 6 will be:
6 % 5= 1