我在控制器操作中使用了选择列表项,并通过传入参数将选择列表项值传递给另一个控制器操作,但没有在另一个控制器操作中获取任何值
//第一个控制器动作
List<SelectListItem> dropdownItems = new List<SelectListItem>();
foreach (var item in (IEnumerable)singlecheckbox)
{
int Id = Convert.ToInt32(item);
dropdownItems.AddRange(new[]{
new SelectListItem() { Text = null, Value = Id.ToString() }});
}
return RedirectToAction("mergeletterttofiles123", "managefile", new { dropdownItems, SeatId = seatId });
//第二个控制器动作
public ActionResult mergeletterttofiles123(List<SelectListItem> dropdownItems, int SeatId, string msg)
{
// dropdownItems shows null( 0 count)
}
答案 0 :(得分:0)
作为选项,您可以在会话中存储列表:
...........
//your code
Session["dropdownItems"]=dropdownItems;
RedirectToAction("mergeletterttofiles123", "managefile", new { SeatId = seatId });
然后:
public ActionResult mergeletterttofiles123(int SeatId, string msg)
{
//then get it using something like
var dropdownItems = Session["dropdownItems"] as List<SelectListItem>;
}