如何根据文本框输入和DropDownList选择值过滤MVC4中的webgrid [英] How to filter webgrid in MVC4 based on textbox input and DropDownList selected value
本文介绍了如何根据文本框输入和DropDownList选择值过滤MVC4中的webgrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是mvc4的新手。任何人都可以帮助我如何根据文本框输入和dropdownList选择值的过滤条件绑定webgrid。例如:如果文本框的楼层名称如F1,如果dropdownList选择的值是空置,那么我需要在gridview中显示在该特定楼层空置的所有座位的列表。如果他从下拉列表中选择已阻止应该显示在该楼层中被阻挡的所有座位。请帮帮我。
I am new to mvc4 . can anyone Help me the in how to bind webgrid based on filter conditions from textbox input and dropdownList selected value. For eg : If textbox has Floor name like "F1" and if dropdownList selected value is "vacant" then i need to show in gridview the list of all seats which are vacant in that particular floor.If he selected "Blocked" from dropdown I should display all the seats which are blocked in that floor. Please help me.
推荐答案
您可以在mvc4网格数据中看到以下链接进行搜索,过滤和排序
http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the -entity-framework-in-an-asp-mvc-application
对于下拉选择索引你必须使用jquery
You can see the following link for searching, filtering and sorting in mvc4 grid data
http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application
For dropdown selected index you have to use jquery
@Html.DropDownListFor(model => model.StateID, Enumerable.Empty<SelectListItem>(), "--Select State--")
<script type="text/javascript">
('#CountryID')。change(function(){
var selectedCountry =
('#CountryID').change(function () { var selectedCountry =
(this).val();
if(selectedCountry!= null&& selectedCountry!=''){
(this).val(); if (selectedCountry != null && selectedCountry != '') {
这篇关于如何根据文本框输入和DropDownList选择值过滤MVC4中的webgrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文