0
我有一个ViewData用于生成列表,选择一个项目后,项目信息将显示在文本框中以供查看和编辑。一旦点击保存按钮,它会保存,但列表框没有被更新,如何更新这个列表框,因为我使用的是viewdata?如何使用ViewData更新列表框的值
@Html.ListBox("ListBoxName", new SelectList((IEnumerable<Epic>)ViewData["selectedestimate"], "Id", "Name", "EstimatedTime"), new {@class = "ListBoxClass", @style = "height: 325px;"})
<button id="EpicSaveId" type="submit" class="btn" onclick="SaveEpicInfo((document.getElementById('EpicNameID').value), (document.getElementById('EpicTimeId').value), (document.getElementById('EpicDescriptionID').value))">
一旦点击保存按钮:(JavaScript)的
function SaveEpicInfo(name, time, description) {
$.get('@Url.Action("SaveEditEpic", "Estimate")', { id: eid, epicname: name, epictime: time, epicdescription: description }, function (result) {
alert(result);
});
}
控制器:
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult SaveEditEpic(int id, string epicname, double epictime, string epicdescription)
{
var epic = epicRepository.Select().SingleOrDefault(x => x.Id.Equals(id));
if (epic != null)
{
epic.Name = epicname;
epic.EstimatedTime = epictime;
epic.EpicDescription = epicdescription;
//ViewData["selectedestimate"] = epicRepository.Select().Where(x => x.EstimateId.Equals(ActiveEstimateId)).ToList();
return Json("Epic Saved", JsonRequestBehavior.AllowGet);
}
else
{
return Json("Error");
}
}
对..但我该如何访问它。我如何调用选择数组。在另一个javascript中我有类似于$(“.ListBoxClass”)的东西。click(function(event){var selectedid = $(this).find(“option:selected”).val();这只返回一个 – TMan 2012-04-16 01:02:12
在选择列表中设置一个id,这将与DOM上的'