I have a GridView with a delete Button on each line, to delete that row. This works fine using
CommandName="Delete" property
on the button and the RowDeleting Event on the GridView.
What I want is to use the ModalPopup to make a delete confirmation, but, I can't put this to work. The RowDeleting Event doen's work anymore.
Protected Sub MyGridView_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs)
Dim myConnetion As SqlConnection = New SqlConnection(erpConn)
Dim delCommand As SqlCommand = myConnetion.CreateCommand()
delCommand.CommandText = "myQuery"
delCommand.Parameters.Add("@Adress", SqlDbType.NVarChar).Value = MyGridView.DataKeys(e.RowIndex).Values(0).ToString()
myConnetion.Open()
delCommand.ExecuteNonQuery()
myConnetion.Close()
GetUser()
End Sub
In your case, it won't post back, so that's cause the problem.
By the way, in your case , there are several ModalPopupExtenders and Panels in a page. It is cool but not an efficient way.
I hope this help.
Best regards,
Jonathan
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
the modalpopupextender takes control of its targetcontrol...so in your case the ibDelete button event, which fires the RowDeleting, is being overridden on the client
you have two options:
1) use the old hidden button hack and show your modalpopup programatically. Place another button right above your modalpopupextender and hide it via css...then set your modalpopupextender targetcontrolid to that button... now in your code-behind inside
your gridview_rowcommand event...put a logic statement checking e.commandname ....if it equals "Delete" then call ModalPopupExtender.Show()...
2) create a webmethod that deletes the row manually and call it with the onokscript via the modalpopupextender
cseven
Member
23 Points
139 Posts
Confirm GridView row delete with ModalPopup
Aug 31, 2007 10:44 AM|LINK
Hi,
I have a GridView with a delete Button on each line, to delete that row. This works fine using CommandName="Delete" property on the button and the RowDeleting Event on the GridView.
What I want is to use the ModalPopup to make a delete confirmation, but, I can't put this to work. The RowDeleting Event doen's work anymore.
What should I do?
This is the code:
<ItemTemplate> <asp:ImageButton ID="ibDelete" runat="server" CausesValidation="False" CommandName="Delete" ImageUrl="../../UserFiles/Images/ico_del.gif" ToolTip="delete row"/> <asp:Panel ID="pnlPopUp" runat="server" Style="display: none" CssClass="modalPopup"> <asp:Panel ID="pnlDragPopUp" runat="server" Style="cursor: move;background-color:#DDDDDD;border:solid 1px Gray;color:Black"> <div> <p>Are you sure you want to delete this item?</p> </div> </asp:Panel> <div> <p style="text-align: center;"> <asp:Button ID="OkButton" runat="server" Text="Yes" /> <asp:Button ID="CancelButton" runat="server" Text="Cancel" /> </p> </div> </asp:Panel> <ajax:ModalPopupExtender ID="ModalPopupExtender" runat="server" TargetControlID="ibDelete" PopupControlID="pnlPopUp" BackgroundCssClass="modalBackground" OkControlID="OkButton" CancelControlID="CancelButton" DropShadow="true" PopupDragHandleControlID="pnlDragPopUp" /> </ItemTemplate>cseven
Member
23 Points
139 Posts
Re: Confirm GridView row delete with ModalPopup
Sep 04, 2007 02:45 PM|LINK
Anyone? [:'(]
Jonathan She...
All-Star
31269 Points
3445 Posts
Re: Confirm GridView row delete with ModalPopup
Sep 05, 2007 09:32 AM|LINK
Hi Cseven,
Would you please remove the OkControlID="OkButton"
<ajax:ModalPopupExtender ID="ModalPopupExtender" runat="server"
TargetControlID="ibDelete"
PopupControlID="pnlPopUp"
BackgroundCssClass="modalBackground"
OkControlID="OkButton" //remove this item
CancelControlID="CancelButton"
DropShadow="true"
PopupDragHandleControlID="pnlDragPopUp" />
In your case, it won't post back, so that's cause the problem.
By the way, in your case , there are several ModalPopupExtenders and Panels in a page. It is cool but not an efficient way.
I hope this help.
Best regards,
Jonathan
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
skywalkr
Member
34 Points
6 Posts
Re: Confirm GridView row delete with ModalPopup
Sep 05, 2007 02:37 PM|LINK
the modalpopupextender takes control of its targetcontrol...so in your case the ibDelete button event, which fires the RowDeleting, is being overridden on the client
you have two options:
1) use the old hidden button hack and show your modalpopup programatically. Place another button right above your modalpopupextender and hide it via css...then set your modalpopupextender targetcontrolid to that button... now in your code-behind inside your gridview_rowcommand event...put a logic statement checking e.commandname ....if it equals "Delete" then call ModalPopupExtender.Show()...
2) create a webmethod that deletes the row manually and call it with the onokscript via the modalpopupextender