none
jquery to call codebehind function to populate asp.net gridview RRS feed

  • Question

  • jQuery(document).ready(function() {
            
                $.ajax({

                    url: "clsUsingJquery/WCFSTcoPyLo.svc/jqState",
                    data: "{}",
                    dataType: "json",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    success: function(str) {
                        var msg = JSON.parse(str.d);
                        $.each(msg, function() {
                            $("#State").append($("<option></option>").val(this['code']).html(this['name']));
                        });
                    },
                    error: function(xhr, err) {
                        alert(xhr.statusText);
                    }
                });

                $("#State").change(function() {
                    $("#Country").html("");
                    var stateId = document.getElementById("State").value;
                    $.ajax({
                        url: "clsUsingJquery/WCFSTcoPyLo.svc/jqcountry",
                        data: '{"stateId":"' + stateId + '"}',
                        dataType: "json",
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        success: function(str) {
                            var msg = JSON.parse(str.d);
                            $.each(msg, function() {
                                $("#Country").append($("<option></option>").val(this['code']).html(this['name']));
                            });
                        },
                        error: function(xhr, err) {
                            alert(xhr.statusText);
                        }
                    });

                });

                $("#Country").change(function() {
                    $("#Pyam").html("");
                    var county = document.getElementById("Country").value;
                    $.ajax({
                        url: "clsUsingJquery/WCFSTcoPyLo.svc/jqPyam",
                        data: '{"county":"' + county + '"}',
                        dataType: "json",
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        success: function(str) {
                            var msg = JSON.parse(str.d);
                            $.each(msg, function() {
                                $("#Pyam").append($("<option></option>").val(this['code']).html(this['name']));
                            });
                        },
                        error: function(xhr, err) {
                            alert(xhr.statusText);
                        }
                    });

                });

                $("#Pyam").change(function() {
                    $("#Location").html("");
                    var pyam = document.getElementById("Pyam").value;
                    $.ajax({
                        url: "clsUsingJquery/WCFSTcoPyLo.svc/jqLocation",
                        data: '{"Pyam":"' + pyam + '"}',
                        dataType: "json",
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        success: function(str) {
                            var msg = JSON.parse(str.d);
                            $.each(msg, function() {
                                $("#Location").append($("<option></option>").val(this['code']).html(this['name']));
                            });
                        },
                        error: function(xhr, err) {
                            alert(xhr.statusText);
                        }
                    }); return false;
                });
            });

     

    I add code on the above.

     

    I retrive data by jquery using this technique.

     

    state is the first dropdown.

     

    country is the second dropdown.

    pyam is the 3rd dropdown.

    location is the 4th dropdown.

     

    but I need to populate data to gridview by selecting 4th dropdown.

     

    please send me solution

     

     

     

    Wednesday, October 6, 2010 10:35 AM