I have an SPGridView with RowCommand event handler defined to handle link events from the grid view. I have a ButtonField on every row defined with CommandName and DataTextField. When my event handler is called though, the argument is always the row index as opposed to the value I passed in datatable for the column specified (which has an integer) for DataTextField. With this, I am unable to figure out the actual data row the link was clicked for, since my data may have changed between the initial render and the postback.

currently the postback link at client side has __doPostBack('<gridid>', '<command>$<rowindex>'), which obviously is missing the DataTextField I had passed.

Is there any way to make the ButtonField include more arguments than just the row index? Basically, I need to be able to add another integer to the argument list that I can retrieve in the command handler. Even some way to override the postback link is acceptable too.

Thanks,
raja.

Additional Info:

the creation of gridview is happening in the C# code that doesn't have an ascx part to it.

Thanks for the response, Thomson. Since I couldn't add large comment, I've edited the question to provide some pseudo code to explain better. Basically, this is a web control without an ascx; it only has the C# code and it is creating the grid view, the data table it binds with, etc. in C# code itself.
–
AnonymousAug 27 '10 at 17:36

Thank you. That sounds like the answer I am looking for; however, it doesn't seem to be working for me. I've set the DataKeyNames property to have 2 fieldnames from my datatables; but the __doPostBack link hasn't changed and still has row index as the parameter to the link. I could be doing something wrong - I'll take some more time and diagnose my code later; for now I've a hacky solution to manipulate the __doPostBack params via jquery.
–
AnonymousSep 10 '10 at 17:27