0

I have the main view with model that gets loaded.

User can click a button, which is an AJAX call it does some processing, returns PartialView like so:

 //values = Dictionary<string,DataTable>(); with some data

 return PartialView("_PartialView1",values)

My ajax call looks like this:

 $.ajax({
        url: '@Url.Action("Process", "Process1")',
        async: true,
        type: 'POST',
        dataType:"html",
        data: {},
            success: function (result) {
                alert("I'm here");
                $('#PartialView').html(result); //I have a Div with this id to render PartialView
            }
     });

With this code, I am successfully able to render the PartialView. I added some text in the partial view and it renders where it should.

Question is about the result. The result will be a Dictionary<string,DataTable> - I have no idea what I have to do in the partial view to accept this data.

In my partial view I tried something like:

 @model Dictionary<string,DataTable> but to no avail

Any idea how I can set up my partial view to have access to this dictionary?

Do I need to return a model with my partial view from the controller?

  • You have to show your partial view. I don' t understand what do you need Dictionary for? – Serge Nov 19 '21 at 23:46
  • when you set `@model Dictionary` are you getting any errors? Are you asking how to access data inside the dictionary? If so, to access the DataTable use `@Model["key"].Select("...");` – S. Walker Nov 20 '21 at 01:32

0 Answers0