Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..........
Posted

1 solution

Double counted your question. Refer answer of this question.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900