I have these models :
public class Project
{
public int ProjectID { get; set; }
public string ProjectTitle { get; set; }
public string ProjectDetails { get; set; }
public Bid SelectedBid { get; set; }
public virtual ICollection<Bid> Bids{ get; set; }
}
public class Bid
{
public int BidID { get; set; }
public string BidTitle { get; set; }
public string BidDetails { get; set; }
public virtual Project Project { get; set; }
}
And I have this Razor :
@if(Model.SelectedBid == null)
{
<dt>
Status :
</dt>
<dd>
Bid not Selected
</dd>
}
else
{
<dt>
Status :
</dt>
<dd>
Bid Selected.
</dd>
}
While debugging in the View, Model has this selected bid :
base = {System.Data.Entity.DynamicProxies.Bid_88FA74D99E4E553A1039D70D55E452C7931E74DCCCA8B5237C0A208B12CCA8C4} But it still accepts null situation.
Here is my controller :
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Project project = db.Projects.Find(id);
return View(project);
}
Can you tell me what is wrong with this code? Thanks.
SelectedBidis null or notSelectedBidis not null and the comparisonSelectedBid == nullis returningtrue?