-2

I am using following expression.

int index = Convert.ToInt32(e.CommandArgument);

I want to get the row index, but the value of index is coming like 0x000000 something.

Paulo Freitas
  • 13,194
  • 14
  • 74
  • 96

1 Answers1

0

Try this:

int index = 0;
int.TryParse(e.CommandArgument as string, out index);

Not sure from your question in which context you're trying to obtain the index, but in the RowDataBound event handler, you would get the index as described here:

How to get index of the gridview row

Community
  • 1
  • 1
IrishChieftain
  • 15,108
  • 7
  • 50
  • 91
  • i use this statement. but it again give that type value. – Avi Banga May 03 '14 at 03:38
  • when i run my project then i click on button field of 2nd row of grid view, them command agrument get the value 1 bt the index gives value 0x00000001. i am using this in RowCommand event of grid view – Avi Banga May 03 '14 at 03:49
  • http://stackoverflow.com/questions/14288168/how-to-get-row-index-according-to-clicked-button-from-asp-net-gridview – IrishChieftain May 03 '14 at 03:51