Showing posts with label row. Show all posts
Showing posts with label row. Show all posts

Monday, March 26, 2012

ConfirmButtonExtender inside Gridview only fires from the first row

I have a gridview, with more than 1 row and the first column is a template in which I have the normal two command buttons Delete and Cancel. Within this template, I have also put a ConfirmButtonExtender for the Delete button to give the user an extra out.

The problem I am having is that the ConfirmButtonExtender only fires for the first row but it does not show up for the subsequent rows. When I click the Delete button for the second row, delete the row is exactly what it does.. without asking if I want to or not as I had set up.

I am wondering if anyone else had the same problem, couldn't find anything online.

Thanks in advance.

Hi

The following works just fine with me,
each button-click (on each row) triggers the confirm message.

 <asp:TemplateField HeaderText="confirm"><ItemTemplate> <asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="Button" /> <cc1:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="Button4"> </cc1:ConfirmButtonExtender></ItemTemplate> </asp:TemplateField>

Please try to replicate the behavior you have ina working code example !
Then I can easily look into it!

Kind regards,
Wim

Saturday, March 24, 2012

Confirm GridView row delete with ModalPopup

Hi,

I have a GridView with a delete Button on each line, to delete that row. This works fine usingCommandName="Delete" propertyon the button and theRowDeleting 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>
 The GridView Event:
 
 
Protected Sub MyGridView_RowDeleting(ByVal senderAs Object,ByVal eAs GridViewDeleteEventArgs)Dim myConnetionAs SqlConnection =New SqlConnection(erpConn)Dim delCommandAs SqlCommand = myConnetion.CreateCommand() delCommand.CommandText ="myQuery" delCommand.Parameters.Add("@dotnet.itags.org.Adress", SqlDbType.NVarChar).Value = MyGridView.DataKeys(e.RowIndex).Values(0).ToString() myConnetion.Open() delCommand.ExecuteNonQuery() myConnetion.Close() GetUser()End Sub

Anyone?Crying


Hi Cseven,

Would you please remove theOkControlID="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 severalModalPopupExtenders and Panels in a page. It is cool but not an efficient way.

I hope this help.

Best regards,

Jonathan


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

Confirm deleting using ModalPopup in GridView

Hi there!

I want to confirm deleting row from GridView using a ModalPopup Extender. Please tell me, how can I do it?

I.e., how to show ModalPopup Panel when user click a Delete button, and how to cansel deleting when user click a Cansel button on ModalPopup Panel and confirm deleting when click a OK Button.

Please, someone, help meCrying


check this article to show modalpopup and do postback when you click the 'OK' button on the ModalPopup.

http://www.aspdotnetcodes.com/ModalPopup_Postback.aspx