如何在mvc4中从kendo网格调用我的控制器中的actionresult方法

时间:2014-02-01 09:51:58

标签: asp.net-mvc-4 methods kendo-ui actionresult

我想将id传递给我的actionresult方法删除

 public ActionResult Delete(Guid AssetTypeId)
    {
        //  _repo.DeleteAssetType(AssetTypeId);
        if (_repo.DeleteAssetType(AssetTypeId) == 1)
        {
            return Index();
        }
        else
        {
            TempData["AlertMessage"] = "The DELETE statement conflicted with the REFERENCE constraint ";
            return Index();
        }
来自剑道网格

.Action("Delete", "AssetType",new { AssetTypeId = "#=AssetTypeId#"  }))  

1 个答案:

答案 0 :(得分:0)

我猜您在架构中声明了AssetTypeId。在这种情况下,您无需单独发送。您只需要在删除中捕获模型。删除它应如下所示;您可以在here的官方演示网站上查看详细信息。

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult EditingPopup_Destroy([DataSourceRequest] DataSourceRequest request, ProductViewModel product)
        {
            if (product != null)
            {
                productService.Destroy(product);
            }

            return Json(new[] { product }.ToDataSourceResult(request, ModelState));
        }