My problem seems very common tio me, and I thought I can find my answer online, but I couldn't. I have a drop down list, and based on the selected value, I need to have multiple partial Views. (one selection can have none, the other one have 3, etc.)

I have a partial View that gets a "DriveDetail" object.

I need to load multiple number of these partial Views Dynamically using JQuery.

So far I have

$.ajax({
            url: "TestInput/getTestStationInformation2/" + testStation,
            dataType: "json",
            type: 'post',
            success: function(data) {

                for (var i = 0; i < data.length; i++) {
                    $('#driveDetailDiv').append(data[i]);
                }

            }
        });

I can either return an IEnumerable or List of those Drives.

public JsonResult getTestStationInformation(long id)
    {
        IEnumerable<DriveDetails> aa = repository.listDriveInfo(id);
        return Json(aa);
    }

    public JsonResult getTestStationInformation2(long id)
    {
        List<PartialViewResult> res = new List<PartialViewResult>();
        List<DriveDetails> aa = repository.listDriveInfo(id).ToList();
        for (int i = 0; i < aa.Count(); i++)
        {
            res.Add(PartialView("DriveDetailsPartial", aa[i]));
        }

        return Json( res);
    }

but none of these work.

I have

 $.get('<%= Url.Action("Details","TestInput", null) %>', function(tmp) {
                    $('#driveDetailDiv').append(tmp);
                });

in my code, but instead of null, I need to send data[0], and get the partialView of data[0]. but I don't know how to send data[0]. When I try

 new {id = data[0])

I get an error.

and When I try to use the second Action which returns a list of partialViews, it doesn't show up when I try to append them.

share|improve this question
Do you mean that you might return a partial view multiple times based on a list of similar items? – Lostdreamer Nov 6 '12 at 21:09
I just saw your comment Lost dreamer. I fixed the problem, I should've used post instead of get. but now I need to somehow get the data of each partial view, and update model. (each partial view is based on an item, and I want to update all the items) – Athena Nov 14 '12 at 22:20
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.