所以我试图显示一些我从数据库中检索到的文本,并希望将它们显示为标签或只是显示在页面上。我无法显示此文本,这就是我所拥有的:
控制器:
public ActionResult _StudentName(int id)
{
id = 12;
var model = new StudentNameModel();
using (var db = new School())
{
var result = from s in db.Students
where s.ID == id
select s.StudentName;
model.StudentName = result.ToString();
}
return View(model);
}
我的模型:
public class StudentNameModel
{
[Display(Name = "Student Name")]
public string StudentName { get; set; }
}
我的观点:
@model Adams.Models.StudentNameModel
<fieldset>
@Html.LabelFor(m => m.StudentName)
@Html.TextBoxFor(m => m.StudentName)
</fieldset>