Click here to Skip to main content
15,312,257 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.
Updated 22-May-14 21:12pm

1 solution

You can see the following link for searching, filtering and sorting in mvc4 grid data

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 = $(this).val();
        if (selectedCountry != null && selectedCountry != '') {
            $.getJSON('@Url.Action("GetStates")', { CountryID: selectedCountry }, function (states) {
                var statesSelect = $('#StateID');
                statesSelect.append($('<option/>', {
                    value: 0,
                    text: '--Select State--'
                $.each(states, function (index, state) {
                    statesSelect.append($('<option/>', {
                        value: state.value,
                        text: state.text

public ActionResult GetStates(int CountryID)
            List<State> states = db.States.Where(a => a.CountryID == CountryID).ToList();
            return Json(
                states.Select(x => new { value = x.StateID, text = x.StateName }),

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900