0
在我的代碼的整體形象已被查看,但我只需要特定的ID值圖象顯示的..如何使用MVC查看關於特定ID值的單個圖像?
<div class="photo">
@foreach (var imgPath in Directory.GetFiles(Server.MapPath("~/ComapnyLogo"), "*.png"))
{
var img = new FileInfo(imgPath);
<img src="@Url.Content(String.Format("~/ComapnyLogo/{0}", img.Name))" />
}
</div>
隱藏標識
<input type="hidden" value="@ViewBag.hdnCompany" id="hdnCompany" />
public ActionResult ViewCompany()
{
var data = dp.Company.SqlQuery("Select * from CompanyRegistration").ToList();
return View(data);
}
如果你只想要一個圖像,爲什麼你遍歷所有這些?隱藏字段中存儲了什麼值?它只是Id嗎?你能用_just_這個Id來製作一個圖像路徑嗎? – maccettura
@maccettura我使用會話ID保存了圖像 –