hi frnds i am beginnner in MVC 3.0. my problem is that i want to bind ActionLink based on my condtion.
this is view detail -------------------------------
@model IEnumerable<mvcapplication2.models.product>
@{
ViewBag.hhrhr = "Index";
}
Index
@Html.ActionLink("Create New", "Create")
@foreach (var item in Model) {
}
ProductName
| Supplier
| Category
| QuantityPerUnit
| UnitPrice
| UnitsInStock
| UnitsOnOrder
| ReorderLevel
| Discontinued
| |
@Html.DisplayFor(modelItem => item.ProductName)
| @Html.DisplayFor(modelItem => item.Supplier.CompanyName)
| @Html.DisplayFor(modelItem => item.Category.CategoryName)
| @Html.DisplayFor(modelItem => item.QuantityPerUnit)
| @Html.DisplayFor(modelItem => item.UnitPrice)
| @Html.DisplayFor(modelItem => item.UnitsInStock)
| @Html.DisplayFor(modelItem => item.UnitsOnOrder)
| @Html.DisplayFor(modelItem => item.ReorderLevel)
| @Html.DisplayFor(modelItem => item.Discontinued)
|
@Html.ActionLink("Edit", "Edit", new { id=item.ProductID }) |
@if (@item.ProductName == "Chai well")
{
@Html.ActionLink("Details", "Details", new { id = item.ProductID})
}
else
{
@Html.ActionLink("Details", "Details", new { id = item.ProductID,catid= item.CategoryID })
}
|
@Html.ActionLink("Delete", "Delete", new { id = item.ProductID })
}
|
---------------------------------------------
in controller class
public ViewResult Details(int id,int catid)
{
Product product = db.Products.Single(p => p.ProductID == id && p.CategoryID== catid);
return View(product);
}
// GET: /Product/Details/5
public ViewResult Details(int id)
{
Product product = db.Products.Single(p => p.ProductID == id);
return View(product);
}
i override the Details method ... then i m gettting this error
The current request for action 'Details' on controller type 'ProductController' is ambiguous between the following action methods:
System.Web.Mvc.ViewResult Details(Int32, Int32) on type MvcApplication2.Controllers.ProductController
System.Web.Mvc.ViewResult Details(Int32) on type MvcApplication2.Controllers.ProductController
pls help me..........