您好我想根据我发送到视图的数据动态构建div布局,我想要制作2行div,当有奇数个模型发送到视图时我希望布局关闭,如您所见每个第二个模型或最后一个模型的代码,并开始div每个奇怪的模型....但当我取消注释评论代码有错误.... (如果我没有弄错类似的东西与C#一起工作,所以我希望它只是synax错误)
@For Each procesData In Model
curElement = curElement + 1
elemNumb = elemNumb + 1
If (curElement = 1) Then
'@<div id="row"> !Comented
End If
@<h3>Element number @elemNumb</h3>
@<h3>@procesData.Name</h3>
@<h3>@procesData.Status.ToString</h3>
@<br />
If (curElement = Model.Count) Then
If (elemNumb = 1) Then
'@</div> !comented
End If
End If
If (curElement = 2) Then
'@</div> !comented
elemNumb = 0
End If
Next
答案 0 :(得分:0)
我调整了.css文件,我设法避免&#39;我的问题,但如果有人知道如何解决这个问题而不绕过原来的问题我会很乐意回答:)
<div id="toggle">
@For Each procesData In Model
curElement = curElement + 1
elemNumb = elemNumb + 1
Dim idName As String = "element" + elemNumb.ToString
@<div id=@idName>
<div class="heading">
@procesData.Name ::::::: Status <img class="statusIMG" id=@procesData.Status.ToString align="right" src="/" />
</div>
<div class="content">
<p>
Dokladniejsze informacje o wskazniku (potrzebne bedzie id zeby wygenerowac partial view! zapamietac)
<br />
np.Html.ActionLink("Edit Me", "Edit", new { id=item.ID })
</p>
</div>
</div>
If (curElement = 2) Then
elemNumb = 0
End If
Next
</div>