I have a DataGridView on my page that has the AutoGenerateSelectButton and AutoGenerateEditButton set to true. When the user clicks on the select link, the selected row is highlighted and information is displayed in another update panel on the page. When the user clicks on the Edit link they can edit the information in the gridview as well as the data displayed in the other UpdatePanel.
I need to prevent the user from clicking on the Edit link on any row except the one selected.
I tried to hide the Edit link using the following code in the RowCreated event:
e.Row.Cells[-].Controls.Visible = false
This worked great. Only the Select link appears.
In the SelectedIndexChanged event I unhide the Edit link and hide the Select link using the following code:
// Show Select Link and Hide Edit Link for previous row selected
GridViewRow prow = gvSchedules.Rows[gvSchedules.SelectedIndex];
prow.Cells.Controls.Visible = false;
prow.Cells.Controls.Visible = true;
GridViewRow row = gvSchedules.SelectedRow;
row.Cells.Controls.Visible = true;
row.Cells.Controls.Visible = false;
This also works great. Only the Edit link appears in the Selected row.
The problem occurs when I click on the Edit Link. I only get the Cancel link. I don't get the Update link. Can anyone tell me how to get the Update link to appear with my current setup? If I don't try and hide/show the Edit/Select links then when I click on Edit, the Update and Cancel links appear and work appropriately. Any help is greatly appreciated!