0

我是 asp.net mvc 的新手。请建议如何使用带有网格的 Ajax 调用。我 @Html.Grid在我的代码中使用过,但找不到刷新网格的方法。添加编辑和删除后,我必须刷新我的网格。如何创建带有添加、编辑和删除弹出窗口的网格?

4

1 回答 1

0

阿贾克斯代码: -

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:");
                    }
                });
            }
        }

将 aboe 代码放在 aspx 文件或 javascript 文件中。

c# 代码

[System.Web.Services.WebMethod(BufferResponse = false, EnableSession = true)]
public static string delete_data(string View_ID)
{
///code
Gridview1.DataSource = Records;
            Gridview1.DataBind();
}
于 2014-06-03T05:39:16.803 回答