【发布时间】:2019-03-05 05:10:15
【问题描述】:
我已经查看了所有关于此的已发布查询,但没有找到解决方案,这是控制器 不知道哪里出错了`
string path = LibConf.dllAppSetting("graphcsvfiles");
System.IO.DirectoryInfo d = new DirectoryInfo(path);
FileInfo[] files = d.GetFiles("*.csv");//Directory.GetFiles(path).Where(s => s.EndsWith("*.csv"));
IEnumerable<SelectListItem> selectLists = files.Select(x => new SelectListItem { Text = x.Name, Value = x.FullName });
MyTestModel m = new MyTestModel;
m.filenames = selectLists;
return View(m);
这是模型
[DisplayName("File")]
public string File { get; set; }
public IEnumerable<SelectListItem> filenames {get; set;}
查看:
<td>
@Html.LabelFor(m => m.File)
@Html.DropDownListFor(m => m.File, new SelectList(Model.filenames, "Text", "Value"), "-select type-", new { @class = "css-class", @style = "margin-right:4px; width:150px;height:28px" })
</td>
【问题讨论】:
-
m.File似乎没有被填充,那么为什么会在下拉列表中选择任何内容? -
@ErikPhilips .. Appologies,我是 mvc 的新手。请帮忙做点什么
标签: c# asp.net-mvc