Passing Json Object Server-Side to MVC ViewResult

Hi:

I have an application in which I need to make a Web Service call to another site that returns a DataSet containing the courses that a particular person has taken - say fields CourseId, CourseTitle, DateRegistered.  I would like to use that DataSet to create a table in a ViewResult so that I can display a table of courses that the person has taken.  I have thought of converting the table into a Json object but am still at a loss as to how to use that data to display a table.  Any help greatly appreciated.  Here's what I have so far:

 public ActionResult CheckHcr()
        {
            var viewModel = new CheckHcrViewModel
            {
                FirstName = Request.QueryString["FirstName"],
                LastName = Request.QueryString["LastName"]
            };

            return View(viewModel);
        }

        [HttpPost]
        public ActionResult CheckHcr(CheckHcrViewModel hcrCheckName)
        {
            if (!ModelState.IsValid)
            {
                return View(hcrCheckName);
            }

            String dsJSON = HcrServices.HC_Qualification_Check(hcrCheckName);

            return RedirectToAction("DisplayCoursesTaken", "ManageHcr", new { ????????? });
}

public static string HC_Qualification_Check(CheckHcrViewModel p)
        {
            var hcr = new Service();

            var dsReturn = new DataSet();

            try
            {
                dsReturn = hcr.ws_HDCO_Qualification_CHECK("SecretWebService", "SecretPassword", p.FirstName, p.LastName, p.BirthDate);
            }
            catch (Exception e)
            { Utilities.LogError(e); }

            var  test = JsonConvert.SerializeObject(dsReturn);

            return test;

        }

Open in new window


Any help greatly appreciated.

RBS
RBSAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Najam UddinCommented:
Get Newtonsoft.Json from nuget

using Newtonsoft.Json;


public string DataTableToJsonWithJsonNet(DataTable table) 
{
   string jsonString=string.Empty;
   jsonString = JsonConvert.SerializeObject(table);
   return jsonString;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RBSAuthor Commented:
Thank you for this Najam - I'm not sure how/where it fits in to my code to allow me to create a table of results.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.