Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc ASP MVC 4显示集合类型_Asp.net Mvc_Vb.net_Asp.net Mvc 3_Razor_Visual Studio 2012 - Fatal编程技术网

Asp.net mvc ASP MVC 4显示集合类型

Asp.net mvc ASP MVC 4显示集合类型,asp.net-mvc,vb.net,asp.net-mvc-3,razor,visual-studio-2012,Asp.net Mvc,Vb.net,Asp.net Mvc 3,Razor,Visual Studio 2012,我的第一个ASP.MVC4项目有一个问题,其中一个页面(到目前为止只有绑定页面)在主内容区域的顶部显示集合的类型。我试过摆脱它,但不知如何是好 我很确定这是我做过的,但无法修复。有什么帮助吗 此处发布 IE9项目调试 控制器 Public Class FailuresController Inherits Controller Function Index(model As IEnumerable(Of QSmartRectificationProvider.Rectifi

我的第一个ASP.MVC4项目有一个问题,其中一个页面(到目前为止只有绑定页面)在主内容区域的顶部显示集合的类型。我试过摆脱它,但不知如何是好

我很确定这是我做过的,但无法修复。有什么帮助吗

此处发布

IE9项目调试

控制器

Public Class FailuresController
    Inherits Controller

    Function Index(model As IEnumerable(Of QSmartRectificationProvider.RectificationFaults)) As ActionResult
        ViewData("Message") = "Open Faults"
        Return View(Session("Failures"))
    End Function

End Class
\u Layout.vbhtml

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>QSmart Rectifications</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/themes/base/css", "~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
    </head>
    <body>
        <header>
            <div class="content-wrapper">
                <div class="float-right">
                    <nav>
                        <ul id="menu">
                            <li>@Html.ActionLink("Log Out", "Index", "Home")</li>
                        </ul>
                    </nav>
                </div>
            </div>
        </header>
        <div id="body">
            @RenderSection("featured", required:=false)
            <section class="content-wrapper main-content clear-fix">
                @RenderBody()
            </section>
        </div>
        <footer>
            <p>@DateTime.Now.Year - JCB Excavators LTD</p>
        </footer>

        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required:=False)
    </body>
</html>
@model QSmartRectification.QSmartRectificationProvider.RectificationFaults

@Code
    ViewData("Title") = "Open Failures"
End Code
@section featured
    <section class="featured">
        <div class="content-wrapper" >
            <p class="site-title float-left">@Html.ActionLink("QSmart Rectification Sign Off", "Index", "Home")</p>
            <input type="image" src="../../Images/Product.png" />
        </div>
    </section>
End Section
<br />
@Using Html.BeginForm()
@Html.ValidationSummary()
@<fieldset class="fieldset clear-fix">
    <legend>Open Faults</legend>
        <section class="content">
            <ul class="column">
                @For Each item As QSmartRectification.QSmartRectificationProvider.RectificationFaults In Model
                    @<li>
                        <section class="block">
                            <a href="#"><img alt="../../Images/Default.png"; src="@String.Format("../../Images/{0}.png", item.MajorAssembly)"/></a>
                            <label class="header">Zone</label>
                            <label>@item.ZoneName</label> 
                            <label class="header">Major Assembly</label>
                            <label>@item.MajorAssembly</label> 
                            <label class="header">Sub Assembly</label>
                            <label>@item.SubAssembly</label> 
                            <label class="header">Component Assembly</label>
                            <label>@item.ComponentAssembly</label> 
                            <label class="header">Business Test</label>
                            <label>@item.BusinessTest</label> 
                            <label class="header">Fault Code</label>
                            <label>@item.FaultCode</label> 
                            <label class="header">Fault Code Detail</label>
                            <label>@item.FaultCodeDetail</label> 
                        </section>
                    </li>
                Next            
            </ul>
        </section>
</fieldset>
End Using
查看源代码片段

    <div id="body">


     <section class="featured">

 <div class="content-wrapper">


  <p class="site-title float-left">
   <a href="/">QSmart Rectification Sign Off</a>
  </p>

              <input type="image" src="../../Images/Product.png" />

 </div>

     </section>

             <section class="content-wrapper main-content clear-fix">
                 System.Linq.OrderedEnumerable`2[QSmartRectification.QSmartRectificationProvider.RectificationFaults,System.Int64] QSmartRectification.QSmartRectificationProvider.RectificationFaults



 <br />
 <form action="/Failures" method="post">
  <div class="validation-summary-valid" data-valmsg-summary="true">
   <ul>
    <li style="display: none;"></li>

   </ul>
  </div>
  <fieldset class="fieldset clear-fix">

       <legend>Open Faults</legend>
           <section class="content">

   <ul class="column">


    <li>

                             <section class="block">
                                 <a href="#"><img alt="../../Images/Default.png" src="../../Images/Hydraulic System.png" ;="" /></a>



                                 <label class="header">Zone</label>
                                 <label>Wheeled SIP 1</label> 
                                 <label class="header">Major Assembly</label>
                                 <label>Hydraulic System</label> 
                                 <label class="header">Sub Assembly</label>
                                 <label>Valve Blocks</label> 
                                 <label class="header">Component Assembly</label>
                                 <label>Hammer Valve</label> 
                                 <label class="header">Business Test</label>
                                 <label>Hammer Hoses</label> 
                                 <label class="header">Fault Code</label>
                                 <label>Adjust / Align</label> 
                                 <label class="header">Fault Code Detail</label>
                                 <label>Fouling</label> 
                             </section>

    </li>


    <li>

                             <section class="block">
                                 <a href="#"><img alt="../../Images/Default.png" src="../../Images/Engine Bay.png" ;="" /></a>



                                 <label class="header">Zone</label>
                                 <label>Wheeled SIP 1</label> 
                                 <label class="header">Major Assembly</label>
                                 <label>Engine Bay</label> 
                                 <label class="header">Sub Assembly</label>
                                 <label>Air Conditioning</label> 
                                 <label class="header">Component Assembly</label>
                                 <label>Compressor</label> 
                                 <label class="header">Business Test</label>
                                 <label>Installation</label> 
                                 <label class="header">Fault Code</label>
                                 <label>Adjust / Align</label> 
                                 <label class="header">Fault Code Detail</label>
                                 <label>Twisted</label> 
                             </section>

    </li>

System.Linq.OrderedEnumerable`2[QSmartRectification.QSmartRectificationProvider.RectificationFaults,System.Int64]QSmartRectification.QSmartRectificationProvider.RectificationFaults
开放断层
  • 区 轮式SIP 1 主要大会 液压系统 分总成 阀块 组件组装 锤阀 商业测试 液压锤软管 故障码 调整/对齐 故障代码详细信息 污垢
  • 区 轮式SIP 1 主要大会 发动机舱 分总成 空调 组件组装 压缩机 商业测试 装置 故障码 调整/对齐 故障代码详细信息 扭曲的
来自WCF服务的模型片段

'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17626"),  _
 System.SerializableAttribute(),  _
 System.Diagnostics.DebuggerStepThroughAttribute(),  _
 System.ComponentModel.DesignerCategoryAttribute("code"),  _
 System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://schemas.datacontract.org/2004/07/vFrame.Service.Qsmart.Sync")>  _
Partial Public Class RectificationFaults
    Inherits Object
    Implements System.ComponentModel.INotifyPropertyChanged

    Private auditScoreField As String

    Private businessTestField As String

    Private commentField As String

    Private componentAssemblyField As String

    Private createdByField As String

    Private failureIDField As Long

    Private failureIDFieldSpecified As Boolean

    Private faultField As String

    Private faultAreaField As String

    Private faultCodeField As String

    Private faultCodeDetailField As String

    Private fixedByCommentField As String

    Private fixedByFaultRectificationIDField As Integer

    Private fixedByFaultRectificationIDFieldSpecified As Boolean

    Private fixedByIDField As Integer

    Private fixedByIDFieldSpecified As Boolean

    Private majorAssemblyField As String

    Private modelNameField As String

    Private shortagePartField As String

    Private subAssemblyField As String

    Private zoneNameField As String
“”
_
部分公共类纠正错误
继承对象
实现System.ComponentModel.INotifyPropertyChanged
私有auditScoreField作为字符串
Private businessTestField作为字符串
私有字段作为字符串
私有componentAssemblyField作为字符串
私有createdByField作为字符串
私人故障字段长度
专用FailureIDFields指定为布尔值
作为字符串的私有faultField
私有FaultArea字段作为字符串
私有faultCodeField作为字符串
私有faultCodeDetailField作为字符串
Private fixedByCommentField作为字符串
Private fixedByFaultRectificationIDField作为整数
Private FixedByFaultRectificationIDFields指定为布尔值
Private fixedByIDField为整数
指定为布尔值的Private FixedByIDFields
Private majorAssemblyField作为字符串
私有modelNameField作为字符串
私有shortagePartField作为字符串
作为字符串的专用子部件字段
私有zoneNameField作为字符串

好的,从
字段集
元素中删除
@
符号,然后更改每个语法,最后建议您使用@html助手,而不是普通的html,代码如下所示

<fieldset class="fieldset clear-fix">
<legend>Open Faults</legend>

<ul>
    @For Each item In Model
        Dim currentItem = item
        @<li>
            <section class="content">
            <a href="#"><img alt="../../Images/Default.png"; src="@String.Format("../../Images/{0}.png", item.MajorAssembly)"/></a>
            </section>
            <label class="header">Zone</label>
            <label>@item.ZoneName</label> 
        </li>
    Next
</ul>
Public Class FailuresController
Inherits Controller

Function Index(model As IEnumerable(Of QSmartRectificationProvider.RectificationFaults)) As ActionResult
    ViewData("Message") = "Open Faults"
    'Return View(Session("Failures"))
    Return View(model) 'this is how the data is sending to the view
End Function

End Class

你能给我们看一下你的“视图源”吗?视图源的一部分已经添加了感谢Jorge的回复。我是新的ASP和这个项目是基于ASP.MVC4模板从微软在VS2012。你的例子不起作用,我不知道你说的HTML助手是什么意思。我已经尝试了你的解决方案(有点麻烦),但它并没有解决我在显示的模型类型方面遇到的问题。只是添加了来自WCF服务的模型。
Public Class FailuresController
Inherits Controller

Function Index(model As IEnumerable(Of QSmartRectificationProvider.RectificationFaults)) As ActionResult
    ViewData("Message") = "Open Faults"
    'Return View(Session("Failures"))
    Return View(model) 'this is how the data is sending to the view
End Function

End Class