我想询问有关使用 asp.net mvc 4 和 sql server 2008 创建配置文件用户页面的问题。在我询问之前。我在控制器中创建了这样的源代码:
namespace SIDLubricants.Controllers
{
public class ProfileController : Controller
{
private Tugas_AkhirEntities db = new Tugas_AkhirEntities();
//
// GET: /Profile/
public ActionResult Index(LoginModel model)
{
var m_cp_customer = from cp in db.M_cp_Customer.Include(m => m.User) where cp.Id == model.Id select cp;
return View(m_cp_customer.ToList());
我创建了这样的视图:
<div id="content" class="span12">
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header well">
<h2>Contact Person Profile</h2>
<table>
<% using (Html.BeginForm()) { %>
<%: Html.AntiForgeryToken() %>
<%: Html.ValidationSummary(true) %>
<tr>
<td><%: Html.DisplayName("Contact Person Customer") %></td>
<td><%: Html.DisplayFor(model => model.kd_cp_customer) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("First Name") %></td>
<td><%: Html.DisplayFor(model => model.NamaDepan) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("Last Name") %></td>
<td><%: Html.DisplayFor(model => model.NamaBelakang) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("Birth Date") %></td>
<td><%: Html.DisplayFor(model => model.Tgl_Lahir) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("Gender") %></td>
<td><%: Html.DisplayFor(model => model.JenisKelamin) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("Address") %></td>
<td><%: Html.DisplayFor(model => model.Alamat) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("City") %></td>
<td><%: Html.DisplayFor(model => model.Kota) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("Province") %></td>
<td><%: Html.DisplayFor(model => model.Provinsi) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("Zip Code") %></td>
<td><%: Html.DisplayFor(model => model.KodePos) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("Phone") %></td>
<td><%: Html.DisplayFor(model => model.Telp) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("Mobile") %></td>
<td><%: Html.DisplayFor(model => model.Mobile) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("Email") %></td>
<td><%: Html.DisplayFor(model => model.Email) %></td>
</tr>
<tr>
<td><%: Html.DisplayName("UserName") %></td>
<td><%: Html.DisplayFor(model => model.User.userName) %></td>
</tr>
<tr>
<td><input type="button" onclick="" value="edit" /></td>
<td> <input type="submit" value="Delete" /></td>
</tr>
<% } %>
</table>
</div>
</div><!--/span-->
</div><!--/row-->
但是,我收到这样的错误消息:
Server Error in '/' Application.
--------------------------------------------------------------------------------
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[SIDLubricants.Models.M_cp_Customer]', but this dictionary requires a model item of type 'SIDLubricants.Models.M_cp_Customer'
你能帮我解决一下吗。我希望最终输出是在操作登录后显示有关配置文件用户的所有数据。谢谢...