Click here to Skip to main content
15,906,081 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,
I was trying to delete record from grid using ajax with jquery. I was able to delete the record from database but at the same time I want to remove the row from grid.

How can I refer, which row has been deleted?

I tried following:
function funDelete(id,row) {
            if (confirm("Do you want to delete this record?")) {
                alert("Step 1");
                try {
                    //GET ID OF RECORD TO BE DELETED                  
                    alert("ID:" + id);
                        type: "POST",
                        url: "QCNotice.aspx/deleteComment",
                        data: "{'args':'" + id + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function() {
                            alert("Record has been deleted..");
                            //CODE TO HIDE THE ROW
                            row.css("background-color", "Red");
                            row.fadeOut(500, function() {
                        error: function(event, request, settings) {
                catch (e) {
                    alert("Error:" + e.message);
            return false;

In the function, I'm passing the record ID
Dim lnkDelete As New LinkButton
lnkDelete = gvRow.FindControl("lnkDelete")
Dim intID As Integer = lnkDelete.CommandArgument
lnkDelete.Attributes.Add("onclick", "return funDelete(" & intID & "," & e.Row.RowIndex & ");")

Even trying, its not working
row.css("background-color", "Red");
                           row.fadeOut(500, function() {

How can I use rowindex to hide row?

Any idea?

Thanks in advance
Updated 7-Jul-11 21:14pm

1 solution

You does'nt need to delete the record from the grid,you just rebind the grid in cliet side for the changes.
Share this answer
dhage.prashant01 8-Jul-11 1:48am    
Basically, I want to put animation after delete so that the user can see the row has been deleted
keyur satyadev 8-Jul-11 3:19am    
You can achieve by color code difference.
What i mean is
if you are also displaying deleted records in grid.
you have to differentiate by color.

Delete - Red
Status(True) - Green

while binding greed you have to check status code and apply row style color in grid accordingly.

Hope you get my point.

Let me know if you have any doubts.
dhage.prashant01 8-Jul-11 4:51am    
Sorry, but I did not get 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