0

I have a webgrid with columns product, quantity, rate, and gross. I have a dropdownlist which has the list of products.

Now based on the selection of the product I need to get the rate for the product.

I think there has to be some callback method to get it.

Eonasdan
  • 7,563
  • 8
  • 55
  • 82
  • There's not an easy way to query data directly from the WebGrid. Can you add other code, like for converting your source collection to JSON? – McGarnagle Sep 27 '12 at 05:14

1 Answers1

0

In project i need to bind state dropdown list based on country selection so i done like this it's below actually in my city view i have 2 dropdown list like country and state.

in my city controller i have action

        public JsonResult State(int countryId)
        {              
            var stateList = CityRepository.GetList(countryId);
            return Json(stateList, JsonRequestBehavior.AllowGet);
        }

and in my view i get all state data like this it's below

<script type="text/javascript">
    function cascadingdropdown() {
        $("#stateID").empty();
        $("#stateID").append("<option value='0'>--Select State--</option>");
        var countryID = $('#countryID').val();
        $.ajax({
            url: "/City/State",
            dataType: 'json',
            data: { countryId: countryID },
            success: function (data) {
                $("#stateID").empty();
                $("#stateID").append("<option value='0'>--Select State--</option>");
                $.each(data, function (index, optiondata) {
                    alert(optiondata.StateName);
                    $("#stateID").append("<option value='" + optiondata.ID + "'>" + optiondata.StateName + "</option>");
                });
            },
            error: function () {
                alert('Faild To Retrieve states.');
            }

        });
    } 
</script>

i think this will help you.

Rajpurohit
  • 1,951
  • 2
  • 16
  • 19