我认为有以下代码
<td>@Html.DropDownListFor(e => e[0].Reason, new List<SelectListItem>
(
new[]
{
new SelectListItem { Text = " -Select- ", Value = "-Select-" },
new SelectListItem { Text = " Price ", Value = "Price" },
new SelectListItem { Text = " 3P ", Value = "3P" },
new SelectListItem { Text = " Freight Collect ", Value = "Freight Collect" },
new SelectListItem { Text = " Billing ", Value = "Billing" },
new SelectListItem { Text = " Business Closure ", Value = "Business Closure" },
new SelectListItem { Text = " Customer Service ", Value = "Customer Service" },
new SelectListItem { Text = " Quality ", Value = "Quality" },
new SelectListItem { Text = " Service ", Value = "Service" },
new SelectListItem { Text = " Business Relocate ", Value = "Business Relocate" },
new SelectListItem { Text = " Change in Relationships ", Value = "Change in Relationships" },
new SelectListItem { Text = " Different Account Code ", Value = "Different Account Code" },
new SelectListItem { Text = " Economic Downturn ", Value = "Economic Downturn" },
new SelectListItem { Text = " BIC ", Value = "BIC" },
new SelectListItem { Text = " Credit/Collections ", Value = "Credit/Collections" }
}
))</td>
Run Code Online (Sandbox Code Playgroud)
每次页面加载时所选值都会发生变化
您能告诉我如何设置所选值吗?
提前致谢。
小智 5
将列表添加到 ViewBag,类型为 IEnumerable-SelectListItem。然后使用这部分代码。
@Html.DropDownListFor(e => e[0].Reason, new SelectList(ViewBag.YourSelectList, "Value", "Text","YourSelectedValue")
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
23435 次 |
最近记录: |