使用webmatix我正在创建下拉列表。但它给了我错误信息。
@code
Dim items As New List(Of SelectListItem)()
items.Add(New SelectListItem() With { _
.Text = "Swimming", _
.Value = "1" _
})
items.Add(New SelectListItem() With { _
.Text = "Cycling", _
.Value = "2", _
.Selected = True _
})
items.Add(New SelectListItem() With { _
.Text = "Running", _
.Value = "3" _
})
End code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
@Html.TextBox("Name") <br/>
@Html.DropDownList(@items)
</body>
</html>
错误消息
Compiler Error Message: BC30201: Expression expected.
Source Error:
Line 26: <body>
Line 27: @Html.TextBox("Name") <br/>
Line 28: @Html.DropDownList(@items)
Line 29: </body>
Line 30: </html>
你能指出我,我在这里做错了吗?
由于 SR
答案 0 :(得分:0)
@Html.DropDownList(@items)
您已经在代码区内了
@Html.DropDownList(items)
应该足够了