Bind Infragistics Webdatagrid on Webdropdown change in MVC

May 20, 2011 at 6:26 AM

Thx, I am facing an issue in binding of webdatagrid on webdropdown change

My code is like this

I have a web dropdown and on change of dropdown I want to bind webdatagrid, I am doing like this and my code is as:-

Controller –For dropdown bind

 public ActionResult ActiveProjects()


            var vm = new ProjectDropDownVM();

            string sOrgId = "abe";

            vm.lstProject = _projectService.GetProjectNames(sOrgId);

            return View(vm);


For grid bind

public JsonResult GetData(int Id)


            var vm = new ProjectDropDownVM();

            vm.lstProject = _projectService.GetProjectNames(Id);

            return this.Json(vm);


View-   Code to bond drop down


        this.wcProject.DataSource = this.Model.lstProject;



Now on drop down change I want to bind webdatagrid, I am doing this by using client event <ClientEvents SelectionChanged="wcProject_SelectionChanged" />

<script language="javascript" type="text/javascript">

        function wcProject_SelectionChanged(sender, eventArgs) {

            // get the text/Value of the selected item

            var selectedProjecty = sender.get_selectedItem().get_text();

            var selectedProjectValue = sender.get_selectedItem().get_value();


            var grid;

            var dataSource;

            var newData;

            var numRows;           

            var newData = $.getJSON("/Projects/GetData", selectedProjectValue, function (data) {


                                grid = $find('<%=WebDataGrid1.ClientID%>');

                                dataSource = grid._get_dataSource();

                                newData = JSON.parse(data.d);


                                var item;

                                for (var i = 0; i < newData.length; i++) {

                                    item = newData[i];






                                numRows = grid.get_rows().get_length();




Plz suggest where i am wrong or we can acheive this by any other way