Hi guys,just teaching myself MVC .net to port a desktop application to the web.
Some background.
I have two tables
Opportunities
OpportunityID
Customer
and some other fields
I also have a table
OPP_Sites
SiteID (identity)
OpportunityID
SiteName
and some other fields
I've created the models for both and auto generated the view/controllers for these.
Now what I want to do is go to my Details view on the Opportunity, hit a url that then takes me to an Index View of the Sites associated with that OpportunityID.
Now I can call the Controller/View from the Opportunity Details view with
@Html.ActionLink("View/Edit Sites", "Index", "Opp_Sites")
and I get a list of all sites, regardless of OpportunityID (as expected)
Now in my Opp_sites/Index controller I have the following code
public ActionResult Index(String OPP)
{
var oppSites = from s in db.Opp_Sites
select s;
oppSites = oppSites.Where(s => s.OpportunityID.Contains(OPP));
return View(oppSites.ToList());
}
So I would have thought that by changing the @html call from my details view to
It would display the same data but filtered by OpportunityID.
But no. As soon as I try to pass data it takes me to the Index view of my Opportunities controller/View.
Doing my head in.