如何绑定选定索引的另一个下拉列表更改下拉列表 [英] how to bind another dropdown on selected index changed of a drop down

查看:86
本文介绍了如何绑定选定索引的另一个下拉列表更改下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我想绑定另一个下拉选择索引使用kendo控件更改当前下拉列表这里是我的代码



i已经使用kendo成功绑定到数据库的第一个下拉列表控制成功



查看: -

 @(Html.Kendo()。DropDownList()
.Name( productComboBox)//名称 组合框 是必需的。它指定 属性 小部件。
.DataTextField( SubjectName)//指定产品 使用组合框作为 a 文本
.DataValueField( ID)//指定哪个属性产品 的关键字> 组合框 as 一个值。
.BindTo(Model)//将 的列表传递给组合框。
.SelectedIndex( 0 )//选择项目 索引 10 。请注意,索引是基于零的。
。活动(e => e
选择 dropdownlist_select
.Change( dropdownlist_change



控制器: -

 DataClasses1DataContext db =  new  DataClasses1DataContext(); 
public ActionResult Index()
{
ViewBag.Message = 欢迎使用ASP.NET MVC!;

return 查看(db.Subject1s.ToList());
}



现在如何对选择下拉菜单执行操作

i做了以下事情

< pre lang =xml> < script 类型 = text / javascript language = javascript >
function dropdownlist_select(){

}

function dropdownlist_change(){
//处理更改事件
}



请告诉我该怎么做才能绑定这个事件同一视图页面上的另一个下拉列表

解决方案

  public  ViewResult Index( )
{
var categories = from c in db.category_master 选择 c;
ViewData [ 类别] = new SelectList(categories, ID 名称);
return 查看(db.akshay_category_master.ToList());

}



 //在视图中

@ Html.DropDownList(类别,ViewBag.applicationList as SelectList,Select,new {onchange =javascript:sendParam();})

// Javascript函数

< script 类型 = text / javascript >
function sendParam(){

window . location = Category / CategoryDe​​tails / + jQuery( #Categories)。val();

}



  //  控制器中的方法 

public ViewResult CategoryDe​​tails( int id)
{

var 结果= 来自 C db.category_master
其中 C.id == id
选择 C;
return 查看( CategoryDe​​tails,Result.ToList());

}







已添加标签。

[/编辑]


here i want to bind another drop down on selected index changed of present dropdown using kendo control here is my code

i have binded first dropdown to database scuccessfully using kendo control scuccessfully

view:-

@(Html.Kendo().DropDownList()
  .Name("productComboBox") //The name of the combobox is mandatory. It specifies the "id" attribute of the widget.
  .DataTextField("SubjectName") //Specifies which property of the Product to be used by the combobox as a text.
  .DataValueField("ID") //Specifies which property of the Product to be used by the combobox as a value.
  .BindTo(Model)   //Pass the list of Products to the combobox.
  .SelectedIndex(0) //Select an item with index 10. Note that the indexes are zero based.
  .Events(e => e
        .Select("dropdownlist_select")
        .Change("dropdownlist_change")
    )
    )


controller:-

DataClasses1DataContext db = new DataClasses1DataContext();
public ActionResult Index()
{
    ViewBag.Message = "Welcome to ASP.NET MVC!";

    return View(db.Subject1s.ToList());
}


now how to perform action on select of dropdown
i did the following thing

<script type="text/javascript" language="javascript">
    function dropdownlist_select() {

    }

    function dropdownlist_change() {
        //Handle the change event
    }


pls tell me what to do on this events to bind another dropdown on the same view page

解决方案

public ViewResult Index()
{
    var categories = from c in db.category_master select c;
    ViewData["Categories"] = new SelectList(categories, "ID", "Name");
    return View(db.akshay_category_master.ToList());

}


// In view 

@Html.DropDownList("Categories", ViewBag.applicationList as SelectList, "Select", new { onchange = "javascript:sendParam();" })

//Javascript Function 

<script type="text/javascript">
function sendParam() {

window.location = "Category/CategoryDetails/" + jQuery("#Categories").val();

}


// that Method in Controller

public ViewResult CategoryDetails(int id)
{

    var Result = from C in db.category_master
                 where C.id == id
                 select C;
    return View("CategoryDetails", Result.ToList());
  
}



[Edit member="Tadit"]
Added pre tags.
[/Edit]


这篇关于如何绑定选定索引的另一个下拉列表更改下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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