如何在MVC 3中创建级联下拉列表 [英] How to create a cascading dropdown list in MVC 3

查看:92
本文介绍了如何在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.

推荐答案

尝试

http://www.deliveron.com/blog/post/Creating-a-Cascading-Dropdown -in-ASPnet-MVC-3-and-jQuery.aspx [ ^ ]

MVC级联Ajax下拉的简单实现 [ ^ ]



此处 [ ^ ]是一段视频。
Try
http://www.deliveron.com/blog/post/Creating-a-Cascading-Dropdown-in-ASPnet-MVC-3-and-jQuery.aspx[^]
Simple Implementation of MVC Cascading Ajax Drop Down[^]

Here[^] is a video.


尝试

http://weblogs.asp.net/raduenuca/archive/2011/03/06/asp-net-mvc-cascading-dropdown-lists- tutorial-part-1-defined-the-problem-and-the-context.aspx [ ^ ]


希望这会对你有所帮助



MVC3级联下拉列表的实现 [ ^ ]
Hope this will help you

Implementation of MVC3 Cascading Dropdown using jQuery[^]


这篇关于如何在MVC 3中创建级联下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆