Click here to Skip to main content
15,911,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I wanna know how to implement a confim message before deleting a row in a gridview but without postback to server I know I need to use jQuery but i dont know how.(i select a checkbox in row gridview and press the delete button to delete, if nonoe of the rows got sleceted i want to display an alert message) this is my aspx page:

http://pastebin.com/WVTXQx1s[^]

and this is the c# code:
http://pastebin.com/cwAhb49F[^]
Posted
Updated 6-Jun-13 17:20pm
v2

1 solution

Write below javascript function on OnClientClick of Delete button.

JavaScript
function checkForDelete() {
        var gridId = '<%=GridView1.ClientID %>';
        var checkedInput = $('#' + gridId).find('tr td input[type="checkbox"]:checked').length;
        var allInput = $('#' + gridId).find('tr td input[type="checkbox"]').length;
        if (checkedInput == 0) {
            alert('Select at least one record');
            return false;
        }

        return true;
    }


C#
<asp:imagebutton id="ButonDeleteClient" runat="server" height="60px" imageurl="~/Images/Delete.png" onclientclick="return checkForDelete();" onclick="ButonDeleteClient_Click" tooltip="Delete selected customer's information" width="60px" xmlns:asp="#unknown" />
 
Share this answer
 
Comments
Kobidavi 7-Jun-13 6:05am    
thanks man it worked perfectly!
vijay__p 9-Jun-13 23:18pm    
Can you please post it as answer if it worked for you?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900