Click here to Skip to main content
15,913,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am new to MVC i have to bind gridview with some report content individually on dropdown selected index change event.

The below code is my dropdown

C#
<div class="form-group col-md-4">
                @Html.DropDownList("bindReports", new List<SelectListItem>()
        {
            new SelectListItem() { Text= "Consolidated Purchases", Value = "cr" },
            new SelectListItem() { Text= "Programs", Value = "gi" },
            new SelectListItem() { Text= "Logistics", Value = "lg" },
            new SelectListItem() { Text= "General Information", Value = "pr" }
        }, "Select Report")
            </div>


If i select Logistics an appropriate sp i need to call with ReportId as Parameter and bind gridview with logistics report details..

What I have tried:

JavaScript
document.ready(function()
{
$('#bindReports').bind('change', function (e) {
            getReportDetails('', '');
        });
}

function getReportDetails() {
    $.ajax({
        url: urlPath,
        success: function (result) {
            
            },
        error: function (xhr, status, error) {
            showAlert("Error...!", error);
        }
    });
}
Posted
Updated 13-Apr-16 23:25pm
v2
Comments
F-ES Sitecore 14-Apr-16 6:02am    
All you have is a drop down with a change event, I don't understand what the question is. Are you expecting someone to write your entire system for you despite knowing nothing about how your data is implemented?

Google how to call MVC actions from jQuery and that will at least help you pass the selected dropdown value to an action and process the results.

In general though it looks like you could do with getting a book on MVC and going through the basics before you try anything more advanced.
sahmed3 15-Apr-16 7:57am    
I have implemented the code i believe it should work, if i found any challenges i'll look for someone's help.

1 solution

Hello,

The below link does the same using ajax and MVC Web Grid,
jQuery Ajax Search and Display In MVC WebGrid in Asp.Net MVC [^]

Enhancing WebGrid with ajax in MVC4[^]

Thanks
 
Share this answer
 

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