Grid with add edit and delete popup

570 Views Asked by At

I am new to asp.net mvc. Please suggest how to use an Ajax call with grid. I have used @Html.Grid in my code but I could not find the method to refresh the grid. I have to refresh my grid after add edit and delete. How can I create a grid with add, edit and delete popup?

1

There are 1 best solutions below

0
On

ajax code:-

function delete_data(delete_id) {
            var param = { Delete_ID: delete_id };
            if (confirm("Are you sure, you want to delete?")) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "default.aspx/delete_date",
                    data: JSON.stringify(param),
                    dataType: "json",
                    success: function (data) {
                        window.location = base_url;
                    },
                    error: function (result) {
                        alert("Error Occurred:");
                    }
                });
            }
        }

put aboe code in aspx file or javascript file.

c# code

[System.Web.Services.WebMethod(BufferResponse = false, EnableSession = true)]
public static string delete_data(string View_ID)
{
///code
Gridview1.DataSource = Records;
            Gridview1.DataBind();
}