本文介绍了如何在MVC 3中创建级联下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public ActionResult Pending_CashDisbursement()
{
ViewData["listPA"] = GetPA();
ViewData["listPSA"] = GetPSA();
return View();
}
public SelectList GetPA()
{
cmn_top objCmn_top = new cmn_top();
DataTable Dt_item = new DataTable();
Dt_item = objCmn_top.Reports_GetPA_CD_Cash_();
var collection = from dtRow in Dt_item.AsEnumerable() select new { Text = dtRow.Field<string>("ch_pacode"), Value = dtRow.Field<string>("ch_pacode") };
var listPA = new SelectList(collection, "value", "text");
return listPA;
}
public SelectList GetPSA()
{
cmn_top objCmn_top = new cmn_top();
DataTable Dt_item = new DataTable();
Dt_item = objCmn_top.Reports_GetPSA_CD_Cash_("L01");
var collection = from dtRow in Dt_item.AsEnumerable() select new { Text = dtRow.Field<string>("PSATXT"), Value = dtRow.Field<string>("PSATXT") };
var listPSA = new SelectList(collection, "value", "text");
return listPSA;
}
我现在有两个列表(GetPA,GetPSA),它将填充视图页面中的两个下拉菜单。
我想用第一个列表(GetPA)的选定值填充第二个列表(GetPSA)。
我如何执行它?我无法做到,请帮助。
I have two lists(GetPA, GetPSA) now which will fill two dropdowns in the view page.
I want to fill the second list(GetPSA) with the selected value of the First List(GetPA).
How do i perform it? I am not able to do it , please help.
推荐答案
这篇关于如何在MVC 3中创建级联下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!