R
Rock
I have a datagrid with the standard Edit and Delete columns that you can add
using the property builder. I added a 3rd column for "Confirm Delete".
When the Delete button is clicked, it runs dg_ItemCommand, and changes the
visible column to say "Confirm Delete". If user clicks on ConfirmDelete, it
then runs the handler dg_DeleteCommand and deletes the record.
The problem is that the column changes for every record so that every record
displays "Confirm Delete", and I'd rather display it only on the record the
user has clicked on.
Does anyone know how to do this? My code is below.
Private Sub dg_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.ItemCommand
If (e.CommandName = "ConfirmDelete") Then
dg.Columns(1).Visible = False
dg.Columns(2).Visible = True
End If
end sub
Private Sub dg_DeleteCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.DeleteCommand
Dim strGuid As String
strGuid = e.Item.Cells(1).Text
Call DeleteRecord(strGuid, strTableName)
dg.Columns(1).Visible = True
dg.Columns(2).Visible = False
End Sub
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
HeaderText="Edit" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete" HeaderText="Delete"
CommandName="ConfirmDelete"></asp:ButtonColumn>
<asp:ButtonColumn Text="Confirm Delete" HeaderText="Confirm Delete"
CommandName="Delete" Visible=false></asp:ButtonColumn>
<asp:ButtonColumn Text="Copy" CommandName="Copy"></asp:ButtonColumn>
<asp:BoundColumn Visible="False" DataField="ID"
ReadOnly="True"></asp:BoundColumn>
<asp:BoundColumn DataField="Yr" HeaderText="Year"></asp:BoundColumn>
using the property builder. I added a 3rd column for "Confirm Delete".
When the Delete button is clicked, it runs dg_ItemCommand, and changes the
visible column to say "Confirm Delete". If user clicks on ConfirmDelete, it
then runs the handler dg_DeleteCommand and deletes the record.
The problem is that the column changes for every record so that every record
displays "Confirm Delete", and I'd rather display it only on the record the
user has clicked on.
Does anyone know how to do this? My code is below.
Private Sub dg_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.ItemCommand
If (e.CommandName = "ConfirmDelete") Then
dg.Columns(1).Visible = False
dg.Columns(2).Visible = True
End If
end sub
Private Sub dg_DeleteCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.DeleteCommand
Dim strGuid As String
strGuid = e.Item.Cells(1).Text
Call DeleteRecord(strGuid, strTableName)
dg.Columns(1).Visible = True
dg.Columns(2).Visible = False
End Sub
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
HeaderText="Edit" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete" HeaderText="Delete"
CommandName="ConfirmDelete"></asp:ButtonColumn>
<asp:ButtonColumn Text="Confirm Delete" HeaderText="Confirm Delete"
CommandName="Delete" Visible=false></asp:ButtonColumn>
<asp:ButtonColumn Text="Copy" CommandName="Copy"></asp:ButtonColumn>
<asp:BoundColumn Visible="False" DataField="ID"
ReadOnly="True"></asp:BoundColumn>
<asp:BoundColumn DataField="Yr" HeaderText="Year"></asp:BoundColumn>