You could do this:
@Html.DropDownListFor(x => x.intClient, ViewBag.Clients)
But I would recommend you to avoid ViewBag/ViewData and profit from your view model:
public ActionResult Index()
{
var model = new TestModel();
model.Clients = new SelectList(new[]
{
new { Value = "1", Text = "client 1" },
new { Value = "2", Text = "client 2" },
new { Value = "3", Text = "client 3" },
}, "Value", "Text");
model.intClient = 2;
return View(model);
}
and in the view:
@Html.DropDownListFor(x => x.intClient, Model.Clients)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…