我觉得这是一个高中男生的错误,但你能向我解释,并提供修复程序为什么这个观点是行不通的:
@ {
INT previousOrderId = 0;
}
@foreach(以模型的VaR项){
< DIV CLASS =的OrderDetail>
@if(item.ID!= previousOrderId){
< DIV CLASS =客户>
&其中,P类=强>订单ID:< / P>
&其中p为H.; @ item.ID&所述; / P>
&其中,P类=强>订购日期:< / P>
< P> @的String.Format({0:绿},TimeZoneInfo.ConvertTime(item.DateInitialised,TimeZoneInfo.FindSystemTimeZoneById(GMT标准时间)))< / P>
&其中,P类=强>客户名称:< / P>
&其中p为H.; @ item.WebsiteUser.Name&所述; / P>
&其中,P类=强>实践名称:< / P>
&其中p为H.; @ item.WebsiteUser.PracticeName&所述; / P>
&其中,P类=强>客户发送电子邮件:LT; / P>
&其中p为H.; @ item.WebsiteUser.EMailAddress&所述; / P>
< / DIV>
}
< DIV CLASS =细节>
<跨度类=强>许可证密钥:LT; / SPAN><跨度>< DIV的风格=宽度:140px;溢出:汽车;> @ item.Licence.LicenceKey< / DIV>&LT ; / SPAN>
<跨度类=强>序列号:<跨度><跨度> @ item.Licence.SerialNumber< / SPAN>
< / DIV>
< DIV CLASS =清零>< / DIV>
< / DIV>
@ {
previousOrderId = item.ID;
}
}
解决方案
缺少一个/附近的跨度标签,缺少附近的类属性的明确的DIV标签和@ {}周围previousOrderId = item.ID是没有必要的。
@ {
INT previousOrderId = 0;
}
@foreach(以模型的VaR项){
< DIV CLASS =的OrderDetail>
@if(item.ID!= previousOrderId){
< DIV CLASS =客户>
&其中,P类=强>订单ID:< / P>
&其中p为H.; @ item.ID&所述; / P>
&其中,P类=强>订购日期:< / P>
< P> @的String.Format({0:绿},TimeZoneInfo.ConvertTime(item.DateInitialised,TimeZoneInfo.FindSystemTimeZoneById(GMT标准时间)))< / P>
&其中,P类=强>客户名称:< / P>
&其中p为H.; @ item.WebsiteUser.Name&所述; / P>
&其中,P类=强>实践名称:< / P>
&其中p为H.; @ item.WebsiteUser.PracticeName&所述; / P>
&其中,P类=强>客户发送电子邮件:LT; / P>
&其中p为H.; @ item.WebsiteUser.EMailAddress&所述; / P>
< / DIV>
}
< DIV CLASS =细节>
<跨度类=强>许可证密钥:LT; / SPAN><跨度>< DIV的风格=宽度:140px;溢出:汽车;> @ item.Licence.LicenceKey< / DIV>&LT ; / SPAN>
<跨度类=强>序列号:< / SPAN><跨度> @ item.Licence.SerialNumber< / SPAN>
< / DIV>
< DIV CLASS =清除>< / DIV>
< / DIV>
previousOrderId = item.ID;
}
I think this is a school boy error but can you explain to me and provide the fix to why this view won't work:
@{
int PreviousOrderId = 0;
}
@foreach (var item in Model) {
<div class="orderdetail">
@if (item.ID != PreviousOrderId){
<div class="customer">
<p class="strong">OrderID:</p>
<p>@item.ID</p>
<p class="strong">Order Date:</p>
<p>@String.Format("{0:g}", TimeZoneInfo.ConvertTime(item.DateInitialised, TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time")))</p>
<p class="strong">Customer Name:</p>
<p>@item.WebsiteUser.Name</p>
<p class="strong">Practice Name:</p>
<p>@item.WebsiteUser.PracticeName</p>
<p class="strong">Customer E-Mail:</p>
<p>@item.WebsiteUser.EMailAddress</p>
</div>
}
<div class="detail">
<span class="strong">Licence Key:</span><span><div style="width:140px; overflow:auto;">@item.Licence.LicenceKey</div></span>
<span class="strong">Serial No:<span><span>@item.Licence.SerialNumber</span>
</div>
<div class="clear></div>
</div>
@{
PreviousOrderId = item.ID;
}
}
解决方案
there is a missing / near a span-tag, a missing " near the class attribute in the clear-div-tag and the @{ } around PreviousOrderId = item.ID wasn't necessary
@{
int PreviousOrderId = 0;
}
@foreach (var item in Model) {
<div class="orderdetail">
@if (item.ID != PreviousOrderId){
<div class="customer">
<p class="strong">OrderID:</p>
<p>@item.ID</p>
<p class="strong">Order Date:</p>
<p>@String.Format("{0:g}", TimeZoneInfo.ConvertTime(item.DateInitialised, TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time")))</p>
<p class="strong">Customer Name:</p>
<p>@item.WebsiteUser.Name</p>
<p class="strong">Practice Name:</p>
<p>@item.WebsiteUser.PracticeName</p>
<p class="strong">Customer E-Mail:</p>
<p>@item.WebsiteUser.EMailAddress</p>
</div>
}
<div class="detail">
<span class="strong">Licence Key:</span><span><div style="width:140px; overflow:auto;">@item.Licence.LicenceKey</div></span>
<span class="strong">Serial No:</span><span>@item.Licence.SerialNumber</span>
</div>
<div class="clear"></div>
</div>
PreviousOrderId = item.ID;
}