I have a gridview. Inside it I have a link button. I want to get the row index of the button which was clicked inside the rowcommand event handler. This can be done using the command argument property. however it is returning empty string and there by getting an exception.
This is the line present inside event handler
Int indexval = Convert.ToInt32(e.commandArgument.ToString());
I've also tried this to get row index. Inside aspx page:
commandArgument= <%#container.DataItem%>
But this also returns empty string Tried like this in rowcommand event
Gridview gr = (gridview)sender;
Int Ind = gr.rows.selectedIndex.
Here Ind value shows as -1
There are some questions on this but all are in VB.net I want the solution to this to be in c#.
PS I'm new to c# and asp.net