I have a grid view will two different button columns. I want to perform a different action depending on what button the user presses. How in the SelectedIndexChanged event do I determine what column was pressed. This is the code I use to generate the columns.
grdAttachments.Columns.Clear();
ButtonField bfSelect = new ButtonField();
bfSelect.HeaderText = "View";
bfSelect.ButtonType = ButtonType.Link;
bfSelect.CommandName = "Select";
bfSelect.Text = "View";
ButtonField bfLink = new ButtonField();
bfLink.HeaderText = "Link/Unlink";
bfLink.ButtonType = ButtonType.Link;
bfLink.CommandName = "Select";
bfLink.Text = "Link";
grdAttachments.Columns.Add(bfSelect);
grdAttachments.Columns.Add(bfLink);
I think it would help if you give the buttons different CommandName properties.
Here is an MSDN example of reading
CommandNamein theGridView_RowCommandevent, which specifically mentions your multiple-button situation: