GridView ButtonField RowCommand Image/Button problem

GridView ButtonField RowCommand Image/Button problem

Post by nx-200 » Fri, 25 Nov 2005 07:54:55


ASP.Net 2.0. I've got a GridView, its got a DataKeyNames set to the ID
of the item that's in a row. I added a ButtonField column, made it a
Button type with my "Remove" text, and when I hit the button, my
CommandArgument in the RowCommand event is my ID field.

Now, when my boss tells me that he wants a little delete picture
instead of the word Remove, I go back, change the ButtonType property
to Image and set the ImageUrl. When I click the image, my RowCommand
event has the row *index* as the CommandArgument, not the ID field as
before.

I can switch back and forth between Button and Image(or Link)
ButtonType to easily replicate this behavior.

Is it supposed to be my DataKeyNames field, or is it supposed to be the
row index?