【发布时间】:2009-09-01 05:01:30
【问题描述】:
我有一个选择值的下拉列表
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Screenname(FormCollection collection)
{
Viewdata["screenname"] = collection[0];
return RedirectToAction("Index", new { ScreenName = ViewData["screenname"] });
}
然后我想在其他类似的操作中访问这个 ViewData
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(FormCollection collection, string screenname)
{
try
{
/// thats my dataobject which creates
DataObj.SaveData(Guid.Empty, collection, screenname);
return RedirectToAction("Index", new { ScreenName = ViewData["screenname"] });
}
catch
{
return View("Error");
}
}
索引看起来像这样......
public ActionResult Index(string ScreenName)
{
///thats my list
GetTable = new GetDataTable(ScreenName);
return View(GetTable);
}
首先,当我选择值并且索引正确执行时......但是当我再次尝试访问视图数据时,它不包含该值,所以任何人都可以提供帮助...... 或替代方法来保存和检索数据。
【问题讨论】:
-
不要使用当前接受的答案(静态变量传递)。
标签: asp.net-mvc