Reputation: 351
I am using LINQ and sending a linq object to the view and trying to show it in a textbox like this
<%=Html.TextBox("petname",Model.PetName) %>
But I am getting error, please suggest how can I show (PetRecord.PetName) which is my linq entity
Thanks Raj
Upvotes: 2
Views: 371
Reputation: 57907
What does your Inherits
property look like:
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
It should inherit whatever model you're sending to the view:
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<PetRecord>" %>
And you should be sending the following to your view from the controller:
public ActionResult ShowPet(int petId)
{
PetRecord pet = repository.GetPetById(petId);
return View(pet);
}
Upvotes: 2