在edmBuilder.EntitySet<Contact>("Contacts");
edmBuilder.EntityType<ContactDto>();
中,我有两种方法(一种显示全部,另一种删除供应商)
VendorControllder
// to display all vendor
public ActionResult Index()
{
SLMEntitiesDB dbContext = new SLMEntitiesDB();
List<Vendor> Vlist = dbContext.Vendors.ToList();
return View(Vlist);
}
// to delete vendor
public ActionResult delv(Vendor VID) //this return null
{
SLMEntitiesDB dbContext = new SLMEntitiesDB();
dbContext.DelV(VID.VID);
return RedirectToAction("Index");
}
是如下过程
DelV
来自供应商索引,我有两个如下的HTML Action链接
create procedure [dbo].[DelV]
(@VID int)
as
begin
Delete from vendor where VID=@VID
end
当我运行应用程序时, @Html.ActionLink("Delete", "delv", new { VID = item.VID },null)
返回null
答案 0 :(得分:0)
您似乎未正确设置ActionLink。 改变这个
@Html.ActionLink("Delete", "delv", new { VID = item.VID },null)
对此
@Html.ActionLink("Delete", "delv", "Vendor", new { VID = item.VID },null)
记住设置为HTML.ActionLink是:链接文本,操作名称,控制器名称,路由值,HTML值