Edward, plenty of good articles like the ones Dan mentions. In the case where
the user won't see your key field (e.g. ID), you have a few options: a) use
datakeyfield, b) use a hidden column in the grid, or c) assign the ID to the
CommandArgument attribute of the button. I always use one of these methods so
I'm not forced to display the ID if I don't want to. It's also helpful in
cases where the ID you show is not the same ID you'd pass to a new page (e.g.
you might want to pass an encrypted version of the ID if the user is going to
see it in a query string, etc.).
"Edward W." wrote:
Let's say I have a dataset with 1 table and it has 3 columns. One of the
columns is a primary key. The number of rows is unknown, but for
simplicity's sake let's say anywhere from 5 to 50 rows. I want to fill a
grid on screen and in each row add a new column and in that column put a
command button. I want every button to have the same event when clicked.
How do I do this so that when the button is clicked but in the click event I
at least get the primary key of the column in the row so that I can uniquely
identify that row?
Thank you.